use strict; use warnings; use File::Slurp qw(read_dir); my $phrase = shift; for my $file (grep { -f } read_dir('./')) { open my $fh, '<', $file or die "can not open $file: $!"; while (<$fh>) { print if /$phrase/; } close $fh; }