Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Help with script to search all files for certain words.

by philipbailey (Chaplain)
on Jan 10, 2011 at 22:46 UTC ( #881554=note: print w/ replies, xml ) Need Help??


in reply to Help with script to search all files for certain words.

Something like this?

#!/usr/bin/perl use strict; use warnings; use File::Find; my $re = get_re(); my @dirs = qw/./; find(\&wanted, @dirs); sub wanted { return unless -f $_; open my $fh, "<", $_ or warn "Couldn't open $_: $!\n"; while (<$fh>) { print "$File::Find::name:$_" if /$re/; } } sub get_re { my @words; while(<DATA>) { chomp; push @words, $_; } return join '|', map { "$_=" } @words; } __DATA__ sales price invoice


Comment on Re: Help with script to search all files for certain words.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881554]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2015-07-07 04:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls