my @table=(); my $row=0; while (@{$array_ref}) { for (1..$columns) { push @{$table[$row]}, shift @{$array_ref}; } $row++; }