ExtUtils-MakeMaker
view release on metacpan or search on metacpan
bundled/JSON-PP/JSON/PP.pm view on Meta::CPAN
my $x = "3"; # some variable containing a string
$x += 0; # numify it, ensuring it will be dumped as a number
$x *= 1; # same thing, the choise is yours.
You can not currently force the type in other, less obscure, ways.
Note that numerical precision has the same meaning as under Perl (so
binary to decimal conversion follows the same rules as in Perl, which
can differ to other languages). Also, your perl interpreter might expose
extensions to the floating point numbers of your platform, such as
infinities or NaN's - these cannot be represented in JSON, and it is an
error to pass those in.
=item Big Number
When C<allow_bignum> is enable,
C<encode> converts C<Math::BigInt> objects and C<Math::BigFloat>
objects into JSON numbers.
=back
bundled/Scalar-List-Utils/Scalar/Util/PP.pm view on Meta::CPAN
local $_ = shift;
# checks from perlfaq4
return 0 if !defined($_);
if (ref($_)) {
require overload;
return overload::Overloaded($_) ? defined(0 + $_) : 0;
}
return 1 if (/^[+-]?[0-9]+$/); # is a +/- integer
return 1 if (/^([+-]?)(?=[0-9]|\.[0-9])[0-9]*(\.[0-9]*)?([Ee]([+-]?[0-9]+))?$/); # a C float
return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i);
0;
}
1;
( run in 0.402 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )