Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tie::refhash::weak(3pm) [debian man page]

Tie::RefHash::Weak(3pm) 				User Contributed Perl Documentation				   Tie::RefHash::Weak(3pm)

NAME
Tie::RefHash::Weak - 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::RefHash DESCRIPTION
The 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. FUNCTIONS
For compatibility with Hash::Util::FieldHash, this module will, upon request, export the following two functions. You may also write "use Tie::RefHash::Weak ':all'". fieldhash %hash This ties the hash and returns a reference to it. fieldhashes \%hash1, \%hash2 ... This ties each hash that is passed to it as a reference. It returns the list of references in list context, or the number of hashes in scalar context. THREAD SAFETY
Tie::RefHash version 1.32 and above have correct handling of threads (with respect to changing reference addresses). If your module requires Tie::RefHash::Weak to be thread aware you need to depend on both Tie::RefHash::Weak and Tie::RefHash version 1.32 (or later). Version 0.02 and later of Tie::RefHash::Weak depend on a thread-safe version of Tie::RefHash anyway, so if you are using the latest version this should already be taken care of for you. 5.10.0 COMPATIBILITY Due to a minor change in Perl 5.10.0 a bug in the handling of magic freeing was uncovered causing segmentation faults. This has been patched but not released yet, as of 0.08. CAVEAT
You can use an LVALUE reference (such as "substr ...") as a hash key, but due to a bug in perl (see <http://rt.perl.org/rt3/Public/Bug/Display.html?id=46943>) it might not be possible to weaken a reference to it, in which case the hash element will never be deleted automatically. AUTHORS
Yuval Kogman <nothingmuch@woobling.org> some maintenance by Hans Dieter Pearcey <hdp@pobox.com> COPYRIGHT &; LICENSE Copyright (c) 2004 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Tie::RefHash, Class::DBI (the live object cache), "Perl_magic_killbackrefs" in mg.c perl v5.10.1 2008-10-18 Tie::RefHash::Weak(3pm)

Check Out this Related Man Page

Tie::Array::Sorted(3pm) 				User Contributed Perl Documentation				   Tie::Array::Sorted(3pm)

NAME
Tie::Array::Sorted - An array which is kept sorted SYNOPSIS
use Tie::Array::Sorted; tie @a, "Tie::Array::Sorted", sub { $_[0] <=> $_[1] }; push @a, 10, 4, 7, 3, 4; print "@a"; # "3 4 4 7 10" DESCRIPTION
This presents an ordinary array, but is kept sorted. All pushes and unshifts cause the elements in question to be inserted in the appropri- ate location to maintain order. Direct stores ("$a[10] = "wibble"") effectively splice out the original value and insert the new element. It's not clear why you'd want to use direct stores like that, but this module does the right thing if you do. If you don't like the ordinary lexical comparator, you can provide your own; it should compare the two elements it is given. For instance, a numeric comparator would look like this: tie @a, "Tie::Array::Sorted", sub { $_[0] <=> $_[1] } Whereas to compare a list of files by their sizes, you'd so something like: tie @a, "Tie::Array::Sorted", sub { -s $_[0] <=> -s $_[1] } LAZY SORTING
If you do more stores than fetches, you may find Tie::Array::Sorted::Lazy more efficient. AUTHOR
Original author: Simon Cozens Current maintainer: Tony Bowden BUGS and QUERIES Please direct all correspondence regarding this module to: bug-Tie-Array-Sorted@rt.cpan.org This module was originall written as part of the Plucene project. However, as Plucene no longer uses this, it is effectively unmaintained. COPYRIGHT AND LICENSE
Copyright (C) 2003-2006 Simon Cozens and Tony Bowden. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. perl v5.8.8 2004-10-10 Tie::Array::Sorted(3pm)
Man Page