Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: pattern match -vs- *ix grep

by Anonymous Monk
on Apr 07, 2005 at 14:25 UTC ( #445697=note: print w/replies, xml ) Need Help??

in reply to pattern match -vs- *ix grep

Actually, I would expect grep to be faster than Perl all the time. Grep is a special purpose tool, accepting simpler regexes than Perl is able to handle. You can do more with Perl than you can with grep, but, IMO, a match between grep and Perl isn't going the best way to "win people over". Best you can hope for is that Perl isn't much slower.

Having said that, I would just write it as:

perl -ne 'BEGIN {$p = shift} print if /$p/' PATTERN files ...
But that's still significant longer than:
grep PATTERN files ...

Replies are listed 'Best First'.
Re^2: pattern match -vs- *ix grep
by ministry (Scribe) on Apr 07, 2005 at 15:01 UTC
    Very impressive!
    All these one-liners and code snippets do a very good job. When using 'time' to check for speed they all seem to be relatively close as I perfmorm my searching through large files. However (just as everyone has been saying) you just cant beat a general purpose tool like /bin/grep for a simple search - there has been a distinct difference in search times (in particular, as the file searches get larger). I guess now Im going to resort to *dazzling* everyone here at work with my fancy perl regex search strings, multi-file searches,etc... :)
    cheers, ev

    Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2023-09-22 12:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found