in reply to Auto Increment "magic" Inquiry
Note that just as in C, Perl doesn't define when the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned.
As I read it, the doc is telling you not to rely on the behavior of your example to be the correct and consistent behavoir, though it may be consistent on your platform.
Another way to interpret it is that Perl uses the same mechanism C uses to perform this op, so however C behaves on your system, Perl should behave the same, but we still won't guarantee that. Thanks to chromatic for correcting this below.
Or are you looking for some explanation like: "$i begins as 0, the pre-increment comes first, making $i=1, then 0+1 is assigned to $i, then $i is post-incremented yielding 2; or is it 1+1 assigned to $i"? But I think that's exactly what the pod is telling you not to try to explain and not to use.$i = $i++ + ++$i;
--Solo
--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Auto Increment "magic" Inquiry
by chromatic (Archbishop) on Jan 04, 2007 at 22:21 UTC | |
Re^2: Auto Increment "magic" Inquiry
by brusimm (Pilgrim) on Jan 04, 2007 at 21:53 UTC | |
by roboticus (Chancellor) on Jan 04, 2007 at 22:22 UTC | |
by jbert (Priest) on Jan 05, 2007 at 12:46 UTC |
In Section
Seekers of Perl Wisdom