Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Its a pretty simple question.. though embarassed to ask but i am totally new in perl

by Laurent_R (Parson)
on Aug 13, 2013 at 16:48 UTC ( #1049316=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Its a pretty simple question.. though embarassed to ask but i am totally new in perl
in thread Its a pretty simple question.. though embarassed to ask but i am totally new in perl

The suggestion was to use next to skip the header line if either you recognize it as a header (for example with a regex), or you know that it is the first line of the file because the $. special variable (line number in the last read file) is equal to 1, something like this:

next if $. == 1;

In my example program, I used a third solution: to read (and discard) one line of input of each file before entering into the while loop. This is slightly faster when reading huge files, since it removes a test from the inner loop, but the difference is probably pretty small.


Comment on Re^3: Its a pretty simple question.. though embarassed to ask but i am totally new in perl
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-10-22 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (112 votes), past polls