use strict; use warnings; while ( my @s = read_chunk() ) { print join " | ", @s; print "\n"; } sub read_chunk { my @stuff = (); while( my $line = ) { chomp $line; push @stuff, $line; last if $. % 4 == 0; } return @stuff; } __DATA__ first1 second1 third1 fourth1 first2 second2 third2 fourth2 first3 second3