sub findstuff { my $file = $File::Find::name; return unless -f "$file"; if (fgrep { /regex/ } "$file") { print "Found regex in $file\n"; } } foreach (@dirs) { find(\@findstuff, $_); }