ministry has asked for the wisdom of the Perl Monks concerning the following question:
monks,
I would think that a small snippet of code like the one below would easily be able to match the speed of grep (of course without all the extra little features), just for a simple pattern match. Can anyone tell me of a better way to do this?
(at the very least to prove to the guys at the office how much cooler perl is, than just the regular shell commands)
#!/usr/bin/perl # $start=shift; $pattern=shift; open(FILE,"$start"); while (<FILE>){ if (/$pattern/) { print; } }
Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
Back to
Seekers of Perl Wisdom