|Linux & Unix Commands - Search Man Pages
Hash::Util(3pm) Perl Programmers Reference Guide Hash::Util(3pm)
Hash::Util - A selection of general-utility hash subroutines
use Hash::Util qw(lock_keys unlock_keys
%hash = (foo => 42, bar => 23);
lock_value (%hash, 'foo');
"Hash::Util" contains special functions for manipulating hashes that don't really warrant
By default "Hash::Util" does not export anything.
5.8.0 introduces the ability to restrict a hash to a certain set of keys. No keys outside
of this set can be added. It also introduces the ability to lock an individual key so it
cannot be deleted and the value cannot be changed.
This is intended to largely replace the deprecated pseudo-hashes.
Restricts the given %hash's set of keys to @keys. If @keys is not given it restricts
it to its current keyset. No more keys can be added. delete() and exists() will still
work, but will not alter the set of allowed keys. Note: the current implementation
prevents the hash from being bless()ed while it is in a locked state. Any attempt to
do so will raise an exception. Of course you can still bless() the hash before you
call lock_keys() so this shouldn't be a problem.
Removes the restriction on the %hash's keyset.
lock_value (%hash, $key);
Locks and unlocks an individual key of a hash. The value of a locked key cannot be
%hash must have already been locked for this to have useful effect.
lock_hash() locks an entire hash, making all keys and values readonly. No value can
be changed, no keys can be added or deleted.
unlock_hash() does the opposite of lock_hash(). All keys and values are made
read/write. All values can be changed and keys can be added and deleted.
Michael G Schwern <firstname.lastname@example.org> on top of code by Nick Ing-Simmons and Jeffrey
Scalar::Util, List::Util, Hash::Util
perl v5.8.0 2002-06-01 Hash::Util(3pm)
All times are GMT -4. The time now is 09:46 AM.