Could you supply the code you wrote?
I wrote this:
use Data::Dumper; use POSIX; @a = (1..100); @b = (1..8); @new_a = (); $maxelmts = POSIX::ceil(scalar @a / scalar @b); $i = 0; foreach (@b) { push @new_a, [grep { defined } @a[$i..($i+$maxelmts)]]; $i += $maxelmts; } print Dumper \@new_a;
Igor 'izut' Sutton
your code, your rules.
In reply to Re: Dividing an array into multiple parts
by izut
in thread Dividing an array into multiple parts
by tsk1979
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |