in reply to file$name.class find - regexp ?

You could use File::Find to solve your problem. But, if you have no need to find files recursively throughout a directory tree (and you have not given any indication that you need to), then I would recommend using opendir and readdir instead.

This approach still does not use a single regex to match the filenames, but it is worth considering. This code is UNTESTED:

use File::Basename; # Get all files in the directory which look like t*.class opendir my $DIR, $dirname or die "can not open $dirname: $!"; my @files = grep { -f "$dirname/$_" } # choose only plain files grep { /t.*\.class$/ } # pattern match readdir $DIR; closedir $DIR; # Now select only those files whose name has exactly one $ # between the "t" and ".class" my @files2; for my $file (@files) { my $base = basename($file); $base =~ s/\$//; push @files2, $file if $base eq 'testfile.class'; }