Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: search for a pattern in file without opening the file

by codeacrobat (Chaplain)
on Jan 30, 2007 at 07:18 UTC ( #597304=note: print w/ replies, xml ) Need Help??


in reply to search for a pattern in file without opening the file

Let perl do the dirty work and use the implicit loop options -n ( see perlrun ).

Check out Tim Mahers Minimal Perl if you are a unixy person and want perl scripts to work similar to unix tools.

/usr/bin/perl -n BEGIN{ @ARGV=qw(the files you want to process); } push @files, $ARGV and close ARGV if /^pattern/; END{ print "matching files @files\n" }


Comment on Re: search for a pattern in file without opening the file
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (14)
As of 2014-10-02 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (60 votes), past polls