my $regex = join '|', map "\Q$_\E?", @filelist; my $find = File::Find::Rule ->file ->name(qr/^(?:$regex)$/) ->start( $dir ); while ( defined( my $html_document = $find->match ) ) { push @found_html, $html_document; } $f_count = scalar @found_html;