[Melbourne-pm] When your variables can't keep their types..

Alfie John alfiej at fastmail.fm
Sun Jun 5 17:42:17 PDT 2016


On Mon, Jun 6, 2016, at 10:29 AM, 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?!"

:(

In future, if you want to be more explicit in types there's:

  http://search.cpan.org/dist/JSON-Typist/lib/JSON/Typist.pm

Alfie


More information about the Melbourne-pm mailing list