use File::Find; my @found; find(sub { push @found, $File::Find::name; }, @directories); ...