Tie::Proxy::Hash

Tie::Proxy::Hash is a Perl module created to efficiently merge & translate hashes.
Download

Tie::Proxy::Hash Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Martyn J. Pearce
  • Publisher web site:
  • http://search.cpan.org/~fluffy/

Tie::Proxy::Hash Tags


Tie::Proxy::Hash Description

Tie::Proxy::Hash is a Perl module created to efficiently merge & translate hashes. Tie::Proxy::Hash is a Perl module created to efficiently merge & translate hashes.SYNOPSIS my (%hash, $ref); $ref = tie %hash, 'Tie::Proxy::Hash', (bart => +{a => 1, b => 2}, maggie => +{a => 5, c => 6, e => 10}, ); $hash{a} == 1; # true $hash{b} == 2; # true (bart supercedes maggie) $hash{c} == 6; # true ! defined $hash{d}; # true $hash{e} == 10; # true $hash{c} = 9; # set in maggie $hash{d} = 12; # set in default $hash{f} = 11; # set in default $ref->add_hash('lisa', +{d => 3, b => 4}); $hash{c} == 9; # true $hash{b} == 2; # true (bart overrides lisa) $hash{d} == 3; # true (lisa overrides default) $hash{f} == 11; # true (only default knows 'f')Proxy hash requests for one or more other hashes, with intermediate value translation.Tie::Proxy::Hash 'merges' hashes by maintaining a list of hashes to look up, and each key requested is looked up in each hash in order until a hit is found. Resultant values may be subject to a translating subr. In this way, hashes may be merged without the cost of by-value copying.A default backing hash is provided to store values not present in other hashes.Tying $ref = tie %hash, 'Tie::Proxy::Hash', bart => +{a => 1, b => 2}, maggie => +{a => 5, c => 6, e => 10} => sub {10*$_}, ;Any arguments passed to tie are palmed off onto add_hash.Retrieving ValuesValues are retrieved by checking each hash in the order of insertion; the first hash found in which a given key exists supplies the value. The value is subject to translation if the given hash has an associated translator.Requirements:· Perl Requirements: · Perl


Tie::Proxy::Hash Related Software