Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: More efficient way to exclude footers

by Laurent_R (Canon)
on Aug 19, 2015 at 18:59 UTC ( [id://1139215]=note: print w/replies, xml ) Need Help??


in reply to Re: More efficient way to exclude footers
in thread More efficient way to exclude footers

while(<INPUT>) { $linecount++ ; next if $linecount <= $numHeaders; # ... }
Why not, but if the file is very large you're doing a $linecount incrementation and a test for every line in the file.
<INPUT> for 1..$numHeaders;
is just reading the first $numHeaders lines of the file and throws them away, and you don't add any overhead for the rest of your file. And, BTW, the $. special variable contains the line count of the last read file handle, so that you don't need the $linecount incrementation.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found