Hash::NoRef is a HASH that store values without increase the reference count (weak references).
This HASH will store it's values without increase the reference count. This can be used to store objects but without interfere in the DESTROY mechanism, since the reference in this HASH won't count.
USAGE
use Hash::NoRef ;
my %hash ;
tie(%hash , 'Hash::NoRef') ;
...
## Or getting a HASH ref tied:
my $hash = new Hash::NoRef() ;
{
my $obj = new FOO() ;
$hash->{obj} = $obj ;
## When we exit this block $obj will be destroied,
## even with it stored in $hash->{obj}
}
$hash->{obj} ## is undef now!
FUNTIONS
SvREFCNT ( REF )
Return the reference count of a reference. If a reference is not paste it will return -1. Dead references will return 0.
SvREFCNT_inc ( REF )
Increase the reference count.
SvREFCNT_dec ( REF )
Decrease the reference count.
EXAMPLES:
my $var = 123 ;
$refcnt = Hash::NoRef::SvREFCNT( $var ) ; ## returns 1
Hash::NoRef::SvREFCNT_inc($var) ; ## adda fake reference, so, it will never die.
Hash::NoRef::SvREFCNT_dec($var) ; ## get back to the normal reference count.
Product's homepage
Requirements:
· Perl