.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Tie::RefHash 3perl" .TH Tie::RefHash 3perl 2024-03-06 "perl v5.38.2" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tie::RefHash \- Use references as hash keys .SH VERSION .IX Header "VERSION" version 1.40 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 4 \& require 5.004; \& use Tie::RefHash; \& tie HASHVARIABLE, \*(AqTie::RefHash\*(Aq, LIST; \& tie HASHVARIABLE, \*(AqTie::RefHash::Nestable\*(Aq, LIST; \& \& untie HASHVARIABLE; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides the ability to use references as hash keys if you first \f(CW\*(C`tie\*(C'\fR the hash variable to this module. Normally, only the keys of the tied hash itself are preserved as references; to use references as keys in hashes-of-hashes, use Tie::RefHash::Nestable, included as part of Tie::RefHash. .PP It is implemented using the standard perl TIEHASH interface. Please see the \f(CW\*(C`tie\*(C'\fR entry in \fBperlfunc\fR\|(1) and \fBperltie\fR\|(1) for more information. .PP The Nestable version works by looking for hash references being stored and converting them to tied hashes so that they too can have references as keys. This will happen without warning whenever you store a reference to one of your own hashes in the tied hash. .SH EXAMPLE .IX Header "EXAMPLE" .Vb 10 \& use Tie::RefHash; \& tie %h, \*(AqTie::RefHash\*(Aq; \& $a = []; \& $b = {}; \& $c = \e*main; \& $d = \e"gunk"; \& $e = sub { \*(Aqfoo\*(Aq }; \& %h = ($a => 1, $b => 2, $c => 3, $d => 4, $e => 5); \& $a\->[0] = \*(Aqfoo\*(Aq; \& $b\->{foo} = \*(Aqbar\*(Aq; \& for (keys %h) { \& print ref($_), "\en"; \& } \& \& tie %h, \*(AqTie::RefHash::Nestable\*(Aq; \& $h{$a}\->{$b} = 1; \& for (keys %h, keys %{$h{$a}}) { \& print ref($_), "\en"; \& } .Ve .SH "THREAD SUPPORT" .IX Header "THREAD SUPPORT" Tie::RefHash fully supports threading using the \f(CW\*(C`CLONE\*(C'\fR method. .SH "STORABLE SUPPORT" .IX Header "STORABLE SUPPORT" Storable hooks are provided for semantically correct serialization and cloning of tied refhashes. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1), \fBperlfunc\fR\|(1), \fBperltie\fR\|(1) .SH SUPPORT .IX Header "SUPPORT" Bugs may be submitted through the RT bug tracker (or bug\-Tie\-RefHash@rt.cpan.org ). .SH AUTHORS .IX Header "AUTHORS" Gurusamy Sarathy .PP Tie::RefHash::Nestable by Ed Avis .SH CONTRIBUTORS .IX Header "CONTRIBUTORS" .IP \(bu 4 Yuval Kogman .IP \(bu 4 Karen Etheridge .IP \(bu 4 Florian Ragwitz .IP \(bu 4 Jerry D. Hedden .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2006 by יובל קוג'מן (Yuval Kogman) . .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.