Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by philipbailey (Curate)
on Jan 10, 2011 at 22:46 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://881554]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-24 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found