my $n = 5; # print every five lines my $i = 0; for my $item (@array) { print "$item\n"; $i++; print "\n" if $i % $n == 0; }