biohisham and ikegami explained cleanly how you can reference the elements in the first "column" one-by-one in a for loop. If you want to join these elements, you can extend that idiom like this (by storing the values in a new array called @column):
use strict; use warnings; my @AoA = ( [ 'Jan', 10, 20 ], [ 'Feb', 15, 25 ], [ 'Mar', 30, 33 ] ); my @column; for my $month_data (@AoA) { push @column, $month_data->[0]; } print join( ' ', @column ), "\n";
However you can use shorter and cleaner constructs, if you don't need them one-by-one, but all of them at once, as an array for the "column". Try this:
use strict; use warnings; my @AoA = ( [ 'Jan', 10, 20 ], [ 'Feb', 15, 25 ], [ 'Mar', 30, 33 ] ); print join( ' ', map {$_->[0]} @AoA ), "\n"; # prints 'Jan Feb Mar' print join( ' ', map {$_->[1]} @AoA ), "\n"; # prints '10 15 30'
The map expression above (map {$_->[0]} @AoA) creates and returns a new array by implicitly iterating through your array refs ("lines", $AoA[0], $AoA[1] ...), taking the first element ("column", $AoA[0][0], $AoA[1][0] ...) from each and constructing the new array from them. (But of course, if you think this is too much for once, just stick with the first and easier version.)

In reply to Re: Multi dimentions to a single dimentional array by rubasov
in thread Multi dimentions to a single dimentional array by Massyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.