Keep It Simple, Stupid | |
PerlMonks |
Re^4: Hard syntax error or disambiguable parsing?by ack (Deacon) |
on Jan 29, 2009 at 16:44 UTC ( [id://739963]=note: print w/replies, xml ) | Need Help?? |
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 Section
Seekers of Perl Wisdom
|
|