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

Homework - i wish! What the array actually contains is molecular statistics and pharmacokinetic results.

If (and it may in future) contain references how can i print those and not ARRAY(0x860be48) etc?

Thanks

Replies are listed 'Best First'.
Re^3: Group array in threes
by jethro (Monsignor) on Feb 02, 2009 at 13:46 UTC

    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"; }