GotToBTru is right. I'll tell you why...
With print @kmers."\n";, the "." (string concatenation) forces @kemers into a scalar context, which is the number of elements in the array. If you use a comma, print @kmers,"\n"; you get the contents of the @kmers array, but without the automatic output space separator. Using, print "@kmers\n"; is probably what you want? See Examples below...

Of course, you probably want to move the print outside of the loop so that you just get the final result, not the intermediate results for each element?

#!/usr/bin/perl use strict; use warnings; my @AoA = ( ['firstRowCol1 asdf87534', 'firstRowCol2 junk lj6t90'], ['secondRowCol1 mnhibvygt7','secondRowCol2 7d7d5434'] ); my(@kmers); for my $x (@AoA) { for my $y (@$x) { push @kmers, $y =~ /^(\w+)/; #first word of each element print "@kmers\n"; } } __END__ In the above code, print @kmers."\n"; #prints... 1 2 3 4 print @kmers,"\n"; #prints... firstRowCol1 firstRowCol1firstRowCol2 firstRowCol1firstRowCol2secondRowCol1 firstRowCol1firstRowCol2secondRowCol1secondRowCol2 print "@kmers\n"; #prints... firstRowCol1 firstRowCol1 firstRowCol2 firstRowCol1 firstRowCol2 secondRowCol1 firstRowCol1 firstRowCol2 secondRowCol1 secondRowCol2
Update: I noticed that you were using tab characters in the code. This is not a good idea because a number of problems arise. Not the least of which is that there is no standard definition of "how long a tab should be". In your program editor, set the option "convert tabs to spaces". That way the indentation will look the same to me as it does to you even though I'm using a different editor.

Another Update: As per the post from Hippo, there are certainly some folks who disagree with my opinion about tabs. I don't want to re-hash this, especially since this point was not a focus of the OP's original question. For those interested, read the thread comments and make up your own mind.


In reply to Re^3: First word by Marshall
in thread First word by Anonymous Monk

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.