use IO::All; my @wanted_file_names = map { $_->name } grep { $_->name =~ /\.\w{3}/ && $_->slurp =~ /ingy/ } io('my/directory')->all_files;