P
Peter
Hello,
I try to split an array into a couple of arrays the same size.
This is my code and I think its very ugly ;-)
Does anoyone has a better idea?
@list =
("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"
,"18");
$pack =5;
$avg = $#list / $pack + 1;
for(1..$pack+1)
{
@newlist = splice(@list,0,$avg) if @list;
print "@newlist\n";
}
I try to split an array into a couple of arrays the same size.
This is my code and I think its very ugly ;-)
Does anoyone has a better idea?
@list =
("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17"
,"18");
$pack =5;
$avg = $#list / $pack + 1;
for(1..$pack+1)
{
@newlist = splice(@list,0,$avg) if @list;
print "@newlist\n";
}