my $array2d = []; my @list = (split /,/,join (",",@array)); $array2d->[$_%3][int($_/3)]=$list[$_] for (0..$#list);