in reply to Re^2: Using hashref values in constant declarations.
in thread Using hashref values in constant declarations.
A search of MetaCPAN for "lock"
This reminds me of the core module Hash::Util:
#!/usr/bin/env perl use warnings; use strict; use Hash::Util qw/lock_hash/; my %x = ( foo => "bar" ); lock_hash %x; eval { $x{y}++; 1 } or warn $@; eval { $x{foo}="quz"; 1 } or warn $@; __END__ Attempt to access disallowed key 'y' in a restricted hash at lock.pl l +ine 9. Modification of a read-only value attempted at lock.pl line 10.
Although there was some discussion on P5P about removing them a while back, I'm not sure if that will happen.
For completeness, there are also tied hashes, which could implement the same thing.
|
---|