Data::MultiValuedHash

Data::MultiValuedHash - hash whose keys have multiple ordered values.
Download

Data::MultiValuedHash Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Darren R. Duncan
  • Publisher web site:
  • http://search.cpan.org/~duncand/CGI-Portable-0.51/lib/CGI/Portable/AppMultiScreen.pm

Data::MultiValuedHash Tags


Data::MultiValuedHash Description

Data::MultiValuedHash - hash whose keys have multiple ordered values. Data::MultiValuedHash - hash whose keys have multiple ordered values.SYNOPSIS use Data::MultiValuedHash; $mvh = Data::MultiValuedHash->new(); # make empty, case-sensitive (norm) $mvh = Data::MultiValuedHash->new( 1 ); # make empty, case-insensitive $mvh = Data::MultiValuedHash->new( 0, { name => 'John', age => 17, color => 'green', siblings => , pets => , } ); # make new with initial values, case-sensitive keys $mvh->store( age => 18 ); # celebrate a birthday $mvh->push( siblings => 'Tandy' ); # add a family member, returns 4 $mvh->unshift( pets => ); # more pets $does_it = $mvh->exists( 'color' ); # returns true $name = $mvh->fetch_value( 'siblings' ); # returns 'Laura' $name = $mvh->fetch_value( 'siblings', 2 ); # returns 'Julia' $name = $mvh->fetch_value( 'siblings', -1 ); # returns 'Tandy' $rname = $mvh->fetch( 'siblings' ); # returns all 4 in array ref @names = $mvh->fetch( 'siblings' ); # returns all 4 as list $name = $mvh->fetch_value( 'Siblings' ); # returns nothing, wrong case $mv2 = Data::MultiValuedHash->new( 1, $mvh ); # conv to case inse $name = $mv2->fetch_value( 'Siblings' ); # returns 'Laura' this time $is_it = $mvh->ignores_case(); # returns false; like normal hashes $is_it = $mv2->ignores_case(); # returns true $color = $mvh->shift( 'color' ); # returns 'green'; none remain $animal = $mvh->pop( 'pets' ); # returns 'Bird'; three remain %list = $mvh->fetch_all(); # want all keys, all values # returns ( name => , age => , color => [], # siblings => , # pets => ) %list = $mvh->fetch_first(); # want all keys, first values of each # returns ( name => 'John', age => 18, color => undef, # siblings => 'Laura', pets => 'Dog' ) %list = $mvh->fetch_last(); # want all keys, last values of each # returns ( name => 'John', age => 18, color => undef, # siblings => 'Tandy', pets => 'Cat' ) %list = $mvh->fetch_last( ); # want named keys only # returns ( name => 'John', siblings => 'Tandy' ) %list = $mvh->fetch_last( , 1 ); # want complement # returns ( age => 18, color => undef, pets => 'Cat' ) $mv3 = $mvh->clone(); # make a duplicate of myself $mv4 = $mvh->fetch_mvh( 'pets', 1 ); # leave out the pets in this "clone" @list = $mv3->keys(); # returns ('name','age','color','siblings','pets') $num = $mv3->keys(); # whoops, doesn't do what we expect; returns array ref $num = $mv3->keys_count(); # returns 5 @list = $mv3->values(); # returns ( 'John', 18, 'Laura', 'Andrew', 'Julia', 'Tandy', # 'Dog', 'Hamster', 'Cat' ) @num = $mv3->values_count(); # returns 9 @list = $mvh->splice( 'Siblings', 2, 1, ); # replaces 'Julia' with 'James'; returns ( 'Julia' ) $mv3->store_all( { songs => , pets => 'Fish', } ); # adds key 'songs' with values, replaces list of pets with 'fish' $mv3->store_value( 'pets', 'turtle' ); # replaces 'fish' with 'turtle' $mv3->store_value( 'pets', 'rabbit', 1 ); # pets is now $oldval = $mv3->delete( 'color' ); # gets rid of color for good $rdump = $mv3->delete_all(); # return everything as hash of arrays, clear Requirements: · Perl


Data::MultiValuedHash Related Software