in reply to Reading two lines per loop iteration
Why not just read both lines at a time? It even seems to handle the case of the file ending with an odd line correctly.
#! perl -slw use strict; while( my $line = <DATA> . <DATA> ) { print "'$line'"; } __DATA__ 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 1 2 3 4 5 6 an odd record
|
|---|