in reply to Re: matching characters in filename
in thread matching characters in filename

... and in the first example, if you want to limit the files by the number that appears in the filename, one way to do that is:

for my $file (glob '1M01_F*.npt.gro') { next unless $file=~/^1M01_F(\d{5})\.npt\.gro$/ && $1>120 && $1<=150; print "$file\n"; } __END__ 1M01_F00121.npt.gro 1M01_F00130.npt.gro 1M01_F00140.npt.gro 1M01_F00150.npt.gro

The doubling of the filename pattern may not be particularly elegant though. Other ways to list files in a directory include readdir, File::Find (which goes into subdirectories too), Path::Class, or Path::Tiny.