in reply to Re: 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

where to use next; because its going in infinite loop .. how should i use next statement fr bth d files !

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

Replies are listed 'Best First'.
Re^3: Its a pretty simple question.. though embarassed to ask but i am totally new in perl
by Laurent_R (Canon) on Aug 13, 2013 at 16:48 UTC

    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.