From what I read, perl does not have a real type for integer or string, for it, any $ variable is scalar.
I recently had problems with an old script that generated JSON objects required by another process, for which the values inside JSON should be integers, after some debugging, I found that due to a simple print function:
JSON :: encode_json
generated a string instead of an integer, here is my example:
use strict;
use warnings;
use JSON;
my $score1 = 998;
my $score2 = 999;
print "score1: ".$score1."\n";
my %hash_object = ( score1 => $score1, score2 => $score2 );
my $json_str = encode_json(\%hash_object);
print "$json_str";
And he outputs:
score1: 998
{"score1":"998","score2":999}
Somehow Perl variables are of type, or at least JSON :: encode_json thinks so.
Is there a way to find this type programmatically and why does this type change when performing an operation such as concatenation above?