#!/usr/bin/perl use strict; use warnings; use File::Find; sub fgrep { my ($regex, $file) = @_; open my $FH, '<', $file or die $!; while (<$FH>) { return 1 if /$regex/; } return 0; } my @found; sub findstuff { my $file = $_; return unless -f $file; my $fullpath = $File::Find::name; if (fgrep(qr/regex/, $file)) { push @found, $fullpath; } } my @dirs = @ARGV; # Populate @dirs. find(\&findstuff, @dirs); print "@found\n";