my $columns = 3; foreach my $x (0 .. $columns - 1) { foreach my $y (0 .. $#array) { print $array->[$y]->[$x] } }