# The filename should be the first arguement $file = $ARGV[0]; # The search string should be the second arguement $searchString = $ARGV[1]; $matchesFound = 0; if (-e $file) { open (INPUTFILE, "<$file") or die "Can't open $file for input.\n"; while ($record = ) { $_ = $record; if (/$searchString/g) { print $record; $matchesFound = $matchesFound + 1; } } close INPUTFILE; print "$matchesFound found.\n"; } else { print "$file doesn't exist.\n"; }