use File::Find::Rule; my @files = File::Find::Rule->file->maxdepth(1)->name('*.xml')->in( @dirs );