Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-12-28 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls