in reply to breaking an array into nearly equal parts

You can use math and slices if you want...

use strict; use warnings; use Data::Dumper; my @array = ( 0 .. 12 ); my @newarray; @newarray[ 0 .. 2 ] = ( [ @array[ 0 .. $#array * .333 ] ], [ @array[ $#array * .333 + 1 .. $#array * .667] ], [ @array[ $#array * .667 + 1 .. $#array ] ] ); print Dumper @newarray;

This will keep the sub-arrays balanced to within one element of each other in size.


Dave