in reply to print every nth element of an array.

I seem to be reading your question differently than the other monks, but I understand that you want to print your array in groups of n, with a blank line between.
my $n = 5; # print every five lines my $i = 0; for my $item (@array) { print "$item\n"; $i++; print "\n" if $i % $n == 0; }
Alternatively (≥v5.12 required):
my $n = 5; while (my ($idx, $item) = each(@array)) { print $item; print "\n" if $idx % $n == $n - 1; }

Replies are listed 'Best First'.
Re^2: print every nth element of an array.
by rinaldi (Initiate) on Jun 06, 2013 at 16:23 UTC

    Thank you. so much. I hadn't thought to do it in that fashion.