foreach $file (<*>) { if ($termlist_file =~ m~^(?:\d{2}_)?\w+$~) { print "$file \n"; } }