post-increment (and post-decrement) return a copy of the variables original value.

Thanks, I hadn't appreciated that but it makes perfect sense and explains the second and third cases.

You haven't tested cached lists at all. You never use the same list twice.

In each case I use (1..2). Is it a different list each time?

In the fifth case I was expecting that $_ is an alias to the elements of the list the foreach is iterating over and that that list would be the elements of the list (1..2) rather than the lvalues of the LHS of the list assignment for the reason you gave previously that the elements of the LHS list are immortal. Furthermore, I expected that the values of $_ would be the same as in the first case where $_ should also be aliased to the elements of the list (1..2). Obviously my understanding / expectation is wrong, but I don't know where. The SV instances displayed by Dump() in the first and fifth cases are different and I don't know why.


In reply to Re^5: list assignment and undef by ig
in thread list assignment and undef by ig

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.