http://www.perlmonks.org?node_id=103512


in reply to Re: Fun with two-dimensional arrays
in thread Fun with two-dimensional arrays

I guess I obscured my question with too much detail about the problem. I'm asking mostly to satisfy my curiosity.

Without all the

$vscr
baggage, my question is: given an array of arrays (of arbitrary dimensions), how do you hit every element, first visiting the first element in each array, then the second, and so on?

For instance, if you had:

my $array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
you'd want to visit in the order 1, 4, 7, 2, 5, 8, 3, 6, 9.

Did that make sense?

update: why @ (in scalar context) and $# didn't occur to me when I posted this, I don't know. That said, mapcar is damn cool.