Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: push to an array lines matching a pattern, and the lines before and after the matching

by JavaFan (Canon)
on Mar 02, 2012 at 21:40 UTC ( [id://957556]=note: print w/replies, xml ) Need Help??


in reply to push to an array lines matching a pattern, and the lines before and after the matching

Your Perl solution slurps in the entire file, one line per element, copies the entire contents to @_, copies that once more into @n lexical to the sub.

Unix grep doesn't do any of that.

I would not be ashamed to call out to an external program. No need to reinvent the wheel, even if the wheel isn't found on CPAN.

  • Comment on Re: push to an array lines matching a pattern, and the lines before and after the matching

Replies are listed 'Best First'.
Re^2: push to an array lines matching a pattern, and the lines before and after the matching
by gianni (Novice) on Mar 04, 2012 at 17:23 UTC
    Perl grep, that is the slow part... and yes, unix grep is 10 times faster

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-23 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found