in reply to Reading multiple lines?

We need more special variables here, especially $.:
local $.; # make sure you're in a restrictive block while ($. < 10) { push @lines, scalar <IN>; last if eof(IN); }
I tested this on a file of 11 lines and one of 9. Worked both ways. If you don't care about uninitialized value errors, you can leave out the local.

Replies are listed 'Best First'.
Re: Re: Reading multiple lines?
by repson (Chaplain) on Nov 28, 2000 at 17:20 UTC
    Unless I'm missing something this code would only get the first block of 10 lines then would stop. Maybe this would be better:
    local $.; while (<IN>) { push @lines , scalar <IN>; next if (($.%10 == 0) and (!eof(IN))); # process @lines @lines = (); # clear }