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

Re: Processing lines after a pattern in a while loop

by kvale (Monsignor)
on Apr 05, 2004 at 16:38 UTC ( #342679=note: print w/replies, xml ) Need Help??


in reply to Processing lines after a pattern in a while loop

Here is an easy way to skip the header:
while(<DATA>){ last if /^#cardtype$/; } while(<DATA>){ # start processing here }

-Mark

Replies are listed 'Best First'.
Re: Re: Processing lines after a pattern in a while loop
by tilly (Archbishop) on Apr 05, 2004 at 17:42 UTC
    And this is the solution that I would use. It is straightforward. It separates out loops which serve different purposes. It avoids the synthetic variable. What's not to like...?
Re: Re: Processing lines after a pattern in a while loop
by halley (Prior) on Apr 06, 2004 at 14:41 UTC
    This is where I wish the magic while (<fh>) was a bit more inclusive, or a bit less special, or something.

    Too bad this doesn't work, because it sure makes for a readable idiom:

    <DATA> until /^#cardtype/; while (<DATA>) { ... }
    The closest readable alternative that works seems to be:
    1 until <DATA> =~ /^#cardtype/; while (<DATA>) { ... }

    --
    [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2023-12-11 21:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?