use warnings; use strict; my $dir = 'test'; opendir my $dh, $dir or die $!; while (readdir $dh){ if (/tpsm_.*/ && -f "$dir/$_"){ print "$dir/$_ is a file\n"; } }