Yeah, I know the differences between a list and an array. And I know that split returns a list, but it is slightly more tricky than that. If you do this:
my $c = qw / 4 6 8 90/;
$c's value becomes the last element of the list (90). But if you do this:
$c = split / /, "the quick brown fox";
$c is now 4, the number of elements of the array (I think this would also trigger a warning that @_ may be overwritten). But if you do this:
$c = (split / /, "the quick brown fox")[2];
now this behaves as an anonymous array et $c is assigned to "brown" (and there no longer any warning, because Perl sort of built an anonymous array). And if you do this:
$c = [split / /, "the quick brown fox"];
$c's value is now something like "ARRAY(0x80359d10)", i.e. an array reference. and you need something like this:
print $c->[2];
to print the third element of the array. This is really an array ref, not an array.

In reply to Re^6: Problem with traversing a two dimensional array (to create an arrayref use [ ] ) by Laurent_R
in thread Problem with traversing a two dimensional array by SiNoEvol

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.