Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://881554]
help
Chatterbox?
[erix]: re: ORMs: sql can easily have many where-clauses so then you'll have to start parsing -- not so easy
[erix]: subqueries, filter-clauses, window functions. etc, etc

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2017-09-25 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (280 votes). Check out past polls.

    Notices?