in reply to Grabbing lines three-by-three from a file

A variation of this is answered in "Re: Reading multiple lines?". Maybe that technique could be of use.

For example, cutting and pasting and altering slightly:

my @buffer; { push @buffer, scalar <IN>; redo unless eof(IN) or @buffer >= 10; ## process @buffer shift @buffer;## [was:] @buffer = (); redo unless eof(IN); }
Change the 10 to 3 and you're nearly done.

-- Randal L. Schwartz, Perl hacker