go ahead... be a heretic | |
PerlMonks |
Grep'ping on Unix without perl-compatible gnu grep - can you do it better?by Tommy (Chaplain) |
on Feb 01, 2013 at 02:15 UTC ( [id://1016422]=perlquestion: print w/replies, xml ) | Need Help?? |
Tommy has asked for the wisdom of the Perl Monks concerning the following question: Are you forced to use a system grep without perl-compatible regex support? (i.e.- no "-P") Let's say you want to grep a file for "foo", but not if it's proceeded by a comment "#" (with possible, legal leading whitespace). How would you grep for that on Unix with it's lame grep? I turn to Perl. Can it be done without perl in one grep? Can this be done in Perl, but more simply? Show me! Meanwhile, at the shell...
I guess I'm looking for a re-usable perl-construct to use as a grep substitute. Something along those lines above. Is there anything more easy than | perl -e 'print for grep { /regex/ } <>
Tommy A mistake can be valuable or costly, depending on how faithfully you pursue correction
Back to
Seekers of Perl Wisdom
|
|