in reply to Re: upto match please, my one-lina!!
in thread upto match please, my one-lina!!
I used "die" because (without eval), the "print @@, exit" combo printed nothing in my code (but it works as advertised in ioannis' code). Perhaps a more enlightened monk could explain why.perl -ne "m/foo/ and die @@ ; shift(@@) if push(@@,$_)>5" myfile.txt
Update: This works too:
This code works on Win32. Use single-quotes for *nix.perl -Mstrict -ne "m/addr/ and eval {print @@; exit}; shift(@@) if pus +h(@@,$_)>5" myfile.txt
"For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken
|
---|