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

You could treat @three like it's a queue, primeing it to 3 lines, shifting off the 1st element, and pushing on the next line as the last element:
#!/usr/bin/perl use strict; use warnings; sub getline { my $line = <DATA>; return undef unless $line; chomp $line; return $line; } my @three = ( &getline(), &getline(), &getline() ); my $line; do { print join("\t",@three),"\n"; @three = ( $three[1], $three[2], $line = &getline() ); } while($line);