in reply to short dir listing

It might be a lot easier to use File::Find:
use File::Find; my @found; find({ wanted => sub { if (/\.bat$/i) # Catches 'bat' and 'BAT' { push(@found, $File::Find::name); } } }, $dir); print "$_\n" foreach (@found);
Might need a bit of tweaking, but I think it's usually better to use modules than to call external programs.