in reply to Reason for this discrepancy with scalar?

If you want to produce JSON with a predefined structure where strings and numbers are distinguished, use Cpanel::JSON::XS::Type.

In Perl, it doesn't matter.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Reason for this discrepancy with scalar?
by LanX (Saint) on Mar 13, 2024 at 22:30 UTC
    I could also imagine using perl objects for this which overload stringification and nummification in a definitive way.

    This has probably been done before.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery