Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Thanks!
Update 2: Because of the explanations given, I understand the phenomenon, but I think it can be explained more explicitly than has been done, so I'm going to give it a shot: First of all, all the expressions will be evaluated when the list is built. That is, before any iteration happens, all of those assignments have been executed. The next thing to understand is that lists may include ordinary values and lvalues; an assignment yields an lvalue, though an expression of which an assignment is just part (e.g., 0+($x=3)) is an ordinary value. What is stored in an lvalue can change even after the lvalue is inserted into the list, so its value depends on when you look at it. The aliasing of a for loop is not fundamental to this. Simply assigning the same list to an array demonstrates the same phenomenon: One final interesting note: postincrement does not yield an lvalue, but preincrement does. The PerlMonk tr/// Advocate In reply to Re: Re: Mysterious for behavior
by Roy Johnson
|
|