in reply to What's wrong with this grep?
Alternately to what JavaFan said, you could also do this:
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.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";
|
---|
In Section
Seekers of Perl Wisdom