use strict; use warnings; use Path::Iterator::Rule; my @dirs = ( '/somepath/to/dir1', '/other/path/to/dir2', ); my $rule = Path::Iterator::Rule->new->file; for my $file ( $rule->all( @dirs ) ) { say $file; # etc. } __END__