Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Skip 21 Lines

by suaveant (Parson)
on Apr 24, 2001 at 19:11 UTC ( [id://75084]=note: print w/replies, xml ) Need Help??


in reply to Re: Skip 21 Lines
in thread Skip 21 Lines

That one is a weird one to get your head around... I never think of it. It is very cool, though. Of course, you could always do...
while (<HANDLE>) { last unless 1..21; } ... rest of processing here ...
to prevent that check running for the following lines, but that's just downright ANAL :)
                - Ant

Replies are listed 'Best First'.
Re: Re: Re: Skip 21 Lines
by virtualsue (Vicar) on Apr 24, 2001 at 23:02 UTC
    last unless 1..21;

    Won't this do the opposite of what was intended and skip all but the first 21 lines of the file?

      No... the while goes through 21 one times, then breaks out... (tho might lose line 22... 1..20 might be needed in this case... but once it exits the loop you either start a new loop or read the reast into an array or whatever, since your placeholder in the file is now at line 22. You see? But that way it isnt perfoming the line check after the 21st line.. not a big efficiency savings... but a bit.
                      - Ant
        OK, I see what you mean. I read it too fast the first time and thought your "rest of processing" bit was inside the first while(). My bad. Yes, you'd need 1..20 for this technique to work.

        I didn't see this response due to a config problem on my part. Now I know what "some notes below your chosen depth" means, sort of. I had not set a depth and assumed that I would see all responses in a thread. Apparently not.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found