use File::Finder; # in the CPAN my @files = File::Finder->depth->type('f')->not->name('*.[ao]')->in('/h');