Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Removing Lines from a file

by cephas (Pilgrim)
on Oct 18, 2006 at 17:33 UTC ( [id://579152]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://579152]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-20 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found