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 | |
by Your Mother (Archbishop) on Jun 15, 2019 at 19:56 UTC | |
by choroba (Cardinal) on Jun 15, 2019 at 20:00 UTC |