I want the script to read the directory I am running the script from and print the contents of any file that has GX in it's title. This is the code needed[I think]. But how do I combine it?
#!/usr/bin/perl
while($x = <*>) {
open(FILE,"$x") || die "Couldn't open $x for reading.\n";
while(<FILE>){
if(/GX/) {
print "$x: $_";
}
}
}
But that only prints out lines and not the content of the files with GX. How can I make it print out the content in the files with GX in their name?
---------- Post updated at 08:23 AM ---------- Previous update was at 08:10 AM ----------
I want it to check the home directory for each file that has GX in the file-name and print out the contents within. Not a list of the files or only lines within a file.