use File::Find; my @files; find(\&wanted, '/path'); sub wanted { if (m/$string/) { push @files, $File::Find::name; } }