use strict; use File::Find; my $glob = shift || '.*'; my $grepTerm = shift || '.*'; my $dir = shift || "."; #following line added 6/19. (Inadvertently left off original posting:) find (\&Wanted, $dir); sub Wanted { return unless /$glob/; open (CURRENT_FILE, $_); my @currentFile = <CURRENT_FILE>; my @foundLines = grep /$grepTerm/, @currentFile; print "In $File::Find::dir/$_:\n" if @foundLines; foreach (@foundLines) { print " $_\n"; } } print "Completed recursive search for files named $glob containing ter +m $grepTerm in directory $dir";
In reply to Recursive Grep by sierrathedog04
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |