use File::Find; my @htmlFiles = (); find sub { push (@htmlFiles, $File::Find::name) if /\.html\z/; }, qw(/home /var/dir); foreach (@htmlFiles){ ...