On 10/3/07, Mahurshi Akilla <[EMAIL PROTECTED]> wrote: > is there an easy way (without iterating through the array) to get a > specified column out of a 2d array?
There is no way in general, easy or hard, to get a column out of an array in Perl without using iteration, even if the iteration is hidden inside a map, foreach, or something similar. So, your answer is "no". > i know you can get it with rows using ( $my2ndrowref = @array[1] ) but > i don't want to transpose all my data right now for this. I think you mean something like this: my @second_row = @{ $array[1] }; print "Second row: @second_row\n"; But now you want a column, instead of a row. Well, if there actually is a column there (we'll assume your data is rectangular), it's easy to extract a copy with map: my @second_col = map $_->[1], @array; print "Second column: @second_col\n"; That's a copy, instead of the original data. If you want to modify it, there's probably a better way to do that. Does that do anything good for you? Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/