http://qs321.pair.com?node_id=805623


in reply to What's wrong with this grep?

Alternately to what JavaFan said, you could also do this:
use File::Slurp; chdir "/tmp/test"; my @files = grep { -f and /^\d{8}\.\d{6}\.host\d\.\d{1,6}$/ } read_dir + "."; print "Got ". scalar(@files) . "\n";
Of course, if the script is going to do anything else, and needs to keep track of the original working directory, use Cwd to find out where you are before you do chdir.