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";