By the way, what's likely happening is that “$var[$a++] + $value” is evaluated fully with its side effects before the rest of the assignment. This leads to accessing “$var[0]”, which is zero, adding value of “$value”, which is one, to get the result one, followed by incrementing “$a”. At this point, the rest of the statement is evaluated: “$var[$a++] = 1”. This time, “$a” is one so “$var[1]” is assigned the value of one (which it already has).
Of course, as druuna described, this is not reliable behaviour and may change at any time theoretically even within the same run of perl interpreter.
|