in reply to Re^2: Group array in threes
in thread Group array in threes

Here is a simple solution with arrayref and one that can cope with array sizes not having multiples of threes

my $array= [1,2,3,4,5]; while (@$array) { push my @r, shift @$array if (@$array); push @r, shift @$array if (@$array); push @r, shift @$array if (@$array); print join(',',@r),"\n"; }