opendir(my $dh, $dir) or die("opendir: $!\n"); my @files = grep { ( !/\.(?:txt|prn|csv)\z/ && /$SrcPattern/ ) || -z } map "$dir/$_", readdir($dh);