in reply to Reading multiple lines?

You won't win any performance, but still the following (untested code) should work:
while (my @chunk = get_chunk(\*IN, 10)) { # etc } sub get_chunk { my $fh = shift; my $count = shift; my @result; push @result, scalar <$fh> foreach 1..$count; return @result; }
UPDATE
Erk. It shouldn't work. :-(

Lots of attempts to read from a possibly closed filehandle. Try this with STDIN and see some interesting behaviour. :-(

Try the following (tested) code:

my $sub = chunker(\*IN, 10); while (my @chunk = $sub->()) { # Do something amusing } sub chunker { my $fh = shift; my $count = shift; return sub { my @ret; while (@ret < $count) { my $line = <$fh>; if (defined($line)) { push @ret, $line; } else { $count = 0; } } return @ret; }; }