in reply to Returning line numbers of a string
open my $file, '<', "myfilename"; while (<$file>){ next unless /mystring/; print "string found at line $."; } close $file; [download]