# untested use File::Find::Rule; my @files = File::Find::Rule->file() ->name('*.html') ->grep($pattern) ->in($dir);