Jim Thomason > Basset-1.04 > Basset::Container::Hash

Download:
Basset-1.04.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 1.00   Source  

Basset::Container::Hash ^

Basset::Container::Hash implements a layered hash. The easiest way to explain is with an example:

 my %x = ('a' => 'b');
 
 tie my %y, 'Basset::Container::Hash', \%x;     #<- %x is the parent of 'y'.
 
 print $x{'a'}; #prints b
 print $y{'a'}; #prints b (inherited from x)
 $y{'a'} = 'foo';
 $y{'z'} = 'bar';
 print $x{'a'}; #prints b
 print $y{'a'}; #prints foo (overriden in y)
 print $x{'z'}; #prints undef (not defined in x
 print $y{'z'}; #prints bar (overridden from x)
 delete $y{'a'};
 print $x{'a'}; #prints b
 print $y{'a'}; #prints b (inherited from x)
 $x{'b'} = 'c';
 print $x{'b'}; #prints c
 print $y{'b'}; #prints c (inherited from x)
syntax highlighting: