[Melbourne-pm] When your variables can't keep their types..
andrew at sericyb.com.au
Sun Jun 5 17:33:46 PDT 2016
On 06/06/16 10:29, Toby Corkindale wrote:
> Thanks for the replies all, but perhaps my point was missed.
> It's not about JSON treating strings and integers differently.
> Note that I did not assign anything to $port between the two calls to
> encode_json(), yet $port changes.
> Despite their name ("variables"), in normal programming languages, variables
> only change when they're assigned to.
> hence the exclamation at the end of the example -- "WTF Perl?!"
Did you get my emails about the way Perl handles SV (Scalar Value)
objects internally, documented in the perlguts manpage? It doesn't seem
to have made it to the list. It can get more WTF than that, because SVs
can have IVs (integer values) and PVs (pointer values, usually strings)
that needn't be related at all if you assign them manually - for
example, $x can be both 1 and '2' at the same time. Don't do that. :)
Stringifying an SV creates the PV.
More information about the Melbourne-pm