in reply to Recursively grep through directory trees.
Off the top of my head:
There's a few optimizations with qr// if you're really into speed, but this should handle 90% of it.use File::Find; my ($search, $ext) = @ARGV; $ext = ".$ext" if defined $ext; @ARGV = (); find sub { push @ARGV, $_ if -f and not $ext or /\Q$ext$/ }, "."; while (<>) { close ARGV if eof; print "$ARGV: $. :$_\n" if /$search/; }
-- Randal L. Schwartz, Perl hacker
|
|---|