Tie::RefHash::WeakTie::RefHash::Weak is a Tie::RefHash subclass with weakened references in the keys. | |
Download |
Tie::RefHash::Weak Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Yuval Kogman
- Publisher web site:
- http://search.cpan.org/~nobull/
Tie::RefHash::Weak Tags
Tie::RefHash::Weak Description
Tie::RefHash::Weak is a Tie::RefHash subclass with weakened references in the keys. Tie::RefHash::Weak is a Tie::RefHash subclass with weakened references in the keys.SYNOPSIS use Tie::RefHash::Weak; tie my %h, 'Tie::RefHash::Weak'; # OR: use Tie::RefHash::Weak 'fieldhash'; fieldhash my %h; { # new scope my $val = "foo"; $h{$val} = "bar"; # key is weak ref print join(", ", keys %h); # contains $val, returns regular reference } # $val goes out of scope, refcount goes to zero # weak references to $val are now undefined keys %h; # no longer contains $val # see also Tie::RefHashThe Tie::RefHash module can be used to access hashes by reference. This is useful when you index by object, for example.The problem with Tie::RefHash, and cross indexing, is that sometimes the index should not contain strong references to the objecs. Tie::RefHash's internal structures contain strong references to the key, and provide no convenient means to make those references weak.This subclass of Tie::RefHash has weak keys, instead of strong ones. The values are left unaltered, and you'll have to make sure there are no strong references there yourself. Requirements: · Perl
Tie::RefHash::Weak Related Software