I have always been under the impression that map assigns to a list, like foreach does, but this doesn't seem to be true. In truth, judging from my experiences as well as the form of a map call, map returns a list that the array or hash you have created is _then_ set to.
That's exactly what's happening. First the map is fully evaluated. It returns a list, and then that list is stored into the array. Similarly, you could use map without storing it (say, in void context, or passing the result to a function like print, or...) and it would evaluate it fully, and then do whatever it's supposed to with it. Put another way, if you were to write
$a = $a + 1;
would you be surpised that it doesn't blow up ("But $a can never be one more than itself!")? No, it first evaluates the new value, and then does the assignment.

In reply to Re: Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map) by Eimi Metamorphoumai
in thread Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map) by Revelation

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.