HashFiller

Programatically fill elements of a hash based in prerequisites
Download

HashFiller Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Luis E. Mu
  • Publisher web site:
  • http://search.cpan.org/~luismunoz/Crypt-PasswdMD5-1.3/PasswdMD5.pm

HashFiller Tags


HashFiller Description

Programatically fill elements of a hash based in prerequisites HashFiller is a Perl module to pogramatically fill elements of a hash based in prerequisites.SYNOPSIS use Hash::Filler; my $hf = new Hash::Filler; # Show how a ->fill() method executes # the rules $Hash::Filler::DEBUG = 1; # Add a set of rules $hf->add('key1', sub { my $hr = shift; ... }, , $pref); $hf->add('key1', sub { my $hr = shift; ... }, [], $pref); $hf->add('key2', sub { my $hr = shift; ... }, , $pref); $hf->add('key3', sub { my $hr = shift; ... }, , $pref); $hf->add(undef, sub { ... }, [], $pref); # Remove rules $hf->remove($rule_id); $hf->loop(0); # Don't try to avoid infinite loops # Test if a key exists using defined() $hf->method($Hash::Filler::DEFINED); my %hash; $hf->fill(\%hash, 'key1'); # Calculate the value of $hash{key1} $hash{'key2'} = 'foo'; # Manually fill a hash position $hf->fill(\%hash, 'key2'); # Calculate the value of $hash{key2} $hr->dump_r_tree(); # Print the key tree my @stats = $hf->stats(); # Obtain statistics about rule invocation my @prof = $hf->profile(); # Obtain profiling information about the rulesHash::Filler provides an interface so that hash elements can be calculated depending in the existence of other hash elements, using user-supplied code references.One of the first uses of this module was inside a server. In this server, the responses to commands came from external sources. For each request, the server needed to contact a number of external sources to calculate the proper answer. These calculations sometimes attempted redundant external accesses, thus increased the response time and load.To help in this situation, the calculations were rewritten to access a hash instead of the external sources directly and this module was used to fill the hash depending on the requirements of the calculations. The external accesses were also improved so that more than one choice or rule existed for each datum, depending on wether prerequisites existed already in the hash or not. Requirements: · Perl


HashFiller Related Software