in reply to Re: Removing Lines from a file
in thread Removing Lines from a file

You can also use -p with a goto:
perl -pe 'goto LINE if /^2nd/' myfile

Which makes since if you look at what it turns into:
$ perl -MO=Deparse -pe 'goto LINE if /^2nd/' myfile LINE: while (defined($_ = <ARGV>)) { goto LINE if /^2nd/; } continue { print $_; } -e syntax OK

Replies are listed 'Best First'.
Re^3: Removing Lines from a file
by johngg (Canon) on Oct 18, 2006 at 18:38 UTC
    Well, that's something new I've learnt. Thank you. Two things in fact as I've never played with -MO=Deparse before and now I can see how useful it can be.

    The only problem with goto is personal in that my first language was Fortran IV; no code blocks and no else clauses meant that your code was full of GO TO's and I became heartily sick of them :)

    Cheers,

    JohnGG