Cirollo has asked for the wisdom of the Perl Monks concerning the following question:
I have a 2D array, and I want to return just a "column" of the array. For example,
So, I want some function that would return (1, 4, 7). The best I've been able to do is this:@ary = ( [1, 2, 3], [4, 5, 6], [7, 8, 9] );
This doesn't seem very "nice," and I don't like the map solution because it isn't terribly suggestive of what the code actually does. Anyone have a better way to do this? Maybe something with hash slices? @ary[0..$#ary][0] doesn't work.map { $_->[0] } @ary[0..$#ary]
Back to
Seekers of Perl Wisdom