Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: ignore first 5 lines of a file

by stephen (Priest)
on Apr 12, 2002 at 22:19 UTC ( #158690=note: print w/ replies, xml ) Need Help??


in reply to ignore first 5 lines of a file

Just for sheer amusement value, here's another way of skipping the first five lines of a file:

while (<>) { do_something($_) if (6..eof()); }

Some explanation is in order. When the range operator .. appears in a scalar context, it becomes the flipflop operator, which behaves very differently and magically. If the argument on either side of it is a constant number, it does an implicit compare with $.. Another way of doing it would be:

while (<>) { next if (1..5); # Whatever here }

stephen


Comment on Re: ignore first 5 lines of a file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (16)
As of 2015-07-29 14:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls