Hash::Util

Offers a selection of general-utility hash subroutines. Starting with Perl 5.8, hashes allow you to restrict access to the data that’s stored in the hash. Individual keys can be locked so they cannot be deleted, nor can their values be changed. Hash::Util is largely intended to replace the deprecated pseudo-hashes.

For example:

 #!/usr/local/bin/perl -w

%hash = (foo => 42, bar => 23);
lock_keys(%hash);

# Now, try to set %hash{'something'}
while(my($key, $value) = each %hash) {
    print "$key -> $value
";
}

unlock_keys(%hash);

You can lock specific values as follows:

#!/usr/local/bin/perl -w

%hash = (foo => 42, bar => 23);
lock_key(%hash, 'foo'),

# Now, try to set 'foo' and see what happens

unlock_keys(%hash, 'foo'),
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.93.169