in reply to Re^3: How could I check if a variable is 'read-only'?
in thread How could I check if a variable is 'read-only'?

What do you make of this?

#!/usr/bin/env perl use strict; use warnings; use JSON; use Scalar::Util qw/ readonly /; my $data = decode_json('{ "val":false }'); print "readonly: ", readonly($data->{val}) ? 'yes' : 'no', "\n"; bless $data->{val};

That produces this for me (on Perl 5.18.2):

$./try readonly: no Modification of a read-only value attempted at ./try line 10.

Replies are listed 'Best First'.
Re^5: How could I check if a variable is 'read-only'?
by Anonymous Monk on Jun 15, 2019 at 19:44 UTC
    cant reproduce that here, try upgrading perl and or json module

      Or cite yours…?

      readonly: no Modification of a read-only value attempted at - line 9. # Successfully installed JSON-4.02 (upgraded from 2.97001) readonly: no Modification of a read-only value attempted at - line 8. # Scalar::Util is up to date. (1.50) perl -MScalar::Util=readonly -MJSON -E 'say readonly(JSON::false) ? "r +eadonly" : "ReAdOnLY"' ReAdOnLY # This is perl 5, version 18, subversion 4 (v5.18.4)