sub readNLines {
my $lines_to_read = shift or die '....';
my @lines_read;
while(<>) {
push( @lines_read, $_ );
last if @lines_read == $lines_to_read;
}
if ( @lines_read != $lines_to_read ) {
# error condition
}
return @lines_read;
}
while (@lines = readNLines(4)) { do_stuff() }
####
while ( my $record = readRecord( ... ) ) { ... }
####
while ( $line1=<> && $line2=<> && $line3=<>... ) { ... }