use File::Find::Rule; my $xml_finder = File::Find::Rule->new()->name(qr/(.*?)\.xml$/i)->start("."); while (my $file = $xml_finder->match() ) { # Do whatever you want with your file name }