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

If you can be reasonably sure that your header will only appear once in your input file, then the following approach can work:

my $header = <>; while (<>) { # process each subsequent record };

If you are really reading from <> instead of manually looping over the files, you cannot be reasonably sure that the header line will not occur again in your input stream as likely each file has its own header line. Then you can check $ARGV to see if the current input file has changed I think, and discard the first header line again.

This approach will of course only work if no header lines come in the middle of your input streamv as is likely when multiple files are concatenated together...

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:32 UTC
    The files being processed are delivered by an overall framework. I will have to see whether that framework can guarantee delivery of only one file at a time. But, in any event, we shift the filename off @ARGV and read it through a filehandle. So I can think we can meet the conditions you describe. Thanks for clarifying this.
    Jim Keenan