in reply to Line-by-line processing of a file where the first line is different

Why not just read one line first?

my $header_row = <>; # process it while (<>) { # process the file }

If you're not sure if the first line is the right one, loop until you find the header, then break out of the header-search loop and loop through the data using a different loop.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

  • Comment on Re: Line-by-line processing of a file where the first line is different
  • Download Code

Replies are listed 'Best First'.
Re^2: Line-by-line processing of a file where the first line is different
by jkeenan1 (Deacon) on Jul 11, 2006 at 11:28 UTC
    Elementary, my dear Watson!

    I know I learned that way back when ... but you can get in such a rut writing code in the same way over and over that you forget the basics!

    I will try it out! Thanks.

    Jim Keenan