http://qs1969.pair.com?node_id=445697


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 ...