my @array2d = (); my $c=0; $array2d[$c%3][int($c++/3)]=$_ for (split /,/, join (",",@array));