foreach my $fn (qw( /what/ever.file /another/file.txt /third/file/here )) { open my $f,'<',$fn or die "Can't open '$fn': $!"; while (<$f>) { # <-- special case, RTFM chomp; # <-- you don't want the newlines, do you? if (/interesting/) { print "Found in line $. of file '$fn': $_\n"; } } close $f; }