http://qs321.pair.com?node_id=593019


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.

$i = $i++ + ++$i;

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.

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.