Case 4 is in fact identical to case 3, since $v in both cases is already a 'my' variable, subject to lexical scoping.

That doesn't make sense to me. If anything, if I understand the documentation, Case 2 and 3 are almost identical and Cases 1 and 4 are almost identical.

In Cases 1 and 2, there is no indication about whether the outer, enclosing scope (outside of the scope of the foreach loop) there is any variable $v wandering around. Since it is not shown, I would presume that the intent is that no such varible exists in exterior scope(s). And I'm not sure that it really matters, in the context of what I'm thinking.

But, if I understand the documentation, in Cases 1 and 4, the use of my in the creation of the loop variable results in a lexically scoped variable and it never appears in any package symbol table.

However, in the situations in Cases 2 and 3, the loop variable is created as if it were created with a local construct. In which case the $v exists in the package symbol table, but a copy is created and used within the scope of the loop and the original value of $v is not touched. At the end of the loop's scope, the original value of $v is restored to the variable in the package symbol table.

So the difference, it seems to me, is whether the package symbol table's variables (symbols?) are used or a new, unseen (by the package symbol table) variable (symbol?) are created for the duration of the loop's scope.

For me, that would seem to make Cases 2 & 3 almost identical and Cases 1 & 4 almost identical.

But then, I'm still learning and could be wrong.

ack Albuquerque, NM

In reply to Re^4: Hard syntax error or disambiguable parsing? by ack
in thread Hard syntax error or disambiguable parsing? by BrowserUk

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.