Re: Perl One-Liners



Prabu schreef:

To print line other than 5th one
perl -ne 'print "$_" if $. != 5' filename

I would make that

perl -wne 'print qq{$_} if $. != 5' filename

or

perl -wne 'print if $. != 5' filename

or better

perl -wne 'print unless $. == 5' filename

or maybe even

perl -wne '$. == 5 or print' filename

and certainly mention to replace the outer '' by "" for Windows.


BTW,

perl -wpe 'next if $. == 5'

doesn't work, see the -MO=Deparse output for the why.

--
Affijn, Ruud

"Gewoon is een tijger."


.



Relevant Pages