|XP is just a number|
It's as if in the past, perl created a temporary variable, a copy of $var that was treated as a number, and used that in the math without messing with $var, and now that's not the case?
All that's changing are the variable's flags, and also the contents of its IV (integer) and NV (float) slots . You can see those internals using the Devel::Peek module - eg:
For me, that outputs:
and you can see that the FLAGS have changed from each step to the next.
Those changes can have a bearing on the values that are printed out.
Additionally, the flags that are currently set, and the ways in which they change have differed over the years - so if JSON is looking at the flags then it is possible that behaviour may change from one version of perl to another.
And if JSON has actually changed the way it treats values based on the flags then that could also change behaviour.
For example, wrt $var in the middle of the script where the flags are (IOK,POK,pIOK,pPOK), it may well have once been the case that the value would be displayed surrounded by quotes if the POK and pPOK flags were set, else no quotes. (This would make sense).
Subsequently, the condition could have changed to not surrounding the value with quotes if the IOK and pIOK flags were set, else surround with double quotes. (This would also make sense.)
Two different treatments - both sane.
The changes to the flags are all part of perl's commitment to "least surprise". It generally works quite well, but there's no way of guaranteeing what programmers will do with the flags.