| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "Tie::RefHash 3perl" |
| 58 |
.TH Tie::RefHash 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide" |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
Tie::RefHash \- Use references as hash keys |
| 65 |
.SH VERSION |
| 66 |
.IX Header "VERSION" |
| 67 |
version 1.40 |
| 68 |
.SH SYNOPSIS |
| 69 |
.IX Header "SYNOPSIS" |
| 70 |
.Vb 4 |
| 71 |
\& require 5.004; |
| 72 |
\& use Tie::RefHash; |
| 73 |
\& tie HASHVARIABLE, \*(AqTie::RefHash\*(Aq, LIST; |
| 74 |
\& tie HASHVARIABLE, \*(AqTie::RefHash::Nestable\*(Aq, LIST; |
| 75 |
\& |
| 76 |
\& untie HASHVARIABLE; |
| 77 |
.Ve |
| 78 |
.SH DESCRIPTION |
| 79 |
.IX Header "DESCRIPTION" |
| 80 |
This module provides the ability to use references as hash keys if you |
| 81 |
first \f(CW\*(C`tie\*(C'\fR the hash variable to this module. Normally, only the |
| 82 |
keys of the tied hash itself are preserved as references; to use |
| 83 |
references as keys in hashes-of-hashes, use Tie::RefHash::Nestable, |
| 84 |
included as part of Tie::RefHash. |
| 85 |
.PP |
| 86 |
It is implemented using the standard perl TIEHASH interface. Please |
| 87 |
see the \f(CW\*(C`tie\*(C'\fR entry in \fBperlfunc\fR\|(1) and \fBperltie\fR\|(1) for more information. |
| 88 |
.PP |
| 89 |
The Nestable version works by looking for hash references being stored |
| 90 |
and converting them to tied hashes so that they too can have |
| 91 |
references as keys. This will happen without warning whenever you |
| 92 |
store a reference to one of your own hashes in the tied hash. |
| 93 |
.SH EXAMPLE |
| 94 |
.IX Header "EXAMPLE" |
| 95 |
.Vb 10 |
| 96 |
\& use Tie::RefHash; |
| 97 |
\& tie %h, \*(AqTie::RefHash\*(Aq; |
| 98 |
\& $a = []; |
| 99 |
\& $b = {}; |
| 100 |
\& $c = \e*main; |
| 101 |
\& $d = \e"gunk"; |
| 102 |
\& $e = sub { \*(Aqfoo\*(Aq }; |
| 103 |
\& %h = ($a => 1, $b => 2, $c => 3, $d => 4, $e => 5); |
| 104 |
\& $a\->[0] = \*(Aqfoo\*(Aq; |
| 105 |
\& $b\->{foo} = \*(Aqbar\*(Aq; |
| 106 |
\& for (keys %h) { |
| 107 |
\& print ref($_), "\en"; |
| 108 |
\& } |
| 109 |
\& |
| 110 |
\& tie %h, \*(AqTie::RefHash::Nestable\*(Aq; |
| 111 |
\& $h{$a}\->{$b} = 1; |
| 112 |
\& for (keys %h, keys %{$h{$a}}) { |
| 113 |
\& print ref($_), "\en"; |
| 114 |
\& } |
| 115 |
.Ve |
| 116 |
.SH "THREAD SUPPORT" |
| 117 |
.IX Header "THREAD SUPPORT" |
| 118 |
Tie::RefHash fully supports threading using the \f(CW\*(C`CLONE\*(C'\fR method. |
| 119 |
.SH "STORABLE SUPPORT" |
| 120 |
.IX Header "STORABLE SUPPORT" |
| 121 |
Storable hooks are provided for semantically correct serialization and |
| 122 |
cloning of tied refhashes. |
| 123 |
.SH "SEE ALSO" |
| 124 |
.IX Header "SEE ALSO" |
| 125 |
\&\fBperl\fR\|(1), \fBperlfunc\fR\|(1), \fBperltie\fR\|(1) |
| 126 |
.SH SUPPORT |
| 127 |
.IX Header "SUPPORT" |
| 128 |
Bugs may be submitted through the RT bug tracker <https://rt.cpan.org/Public/Dist/Display.html?Name=Tie-RefHash> |
| 129 |
(or bug\-Tie\[email protected] <mailto:[email protected]>). |
| 130 |
.SH AUTHORS |
| 131 |
.IX Header "AUTHORS" |
| 132 |
Gurusamy Sarathy <[email protected]> |
| 133 |
.PP |
| 134 |
Tie::RefHash::Nestable by Ed Avis <[email protected]> |
| 135 |
.SH CONTRIBUTORS |
| 136 |
.IX Header "CONTRIBUTORS" |
| 137 |
.IP \(bu 4 |
| 138 |
Yuval Kogman <[email protected]> |
| 139 |
.IP \(bu 4 |
| 140 |
Karen Etheridge <[email protected]> |
| 141 |
.IP \(bu 4 |
| 142 |
Florian Ragwitz <[email protected]> |
| 143 |
.IP \(bu 4 |
| 144 |
Jerry D. Hedden <[email protected]> |
| 145 |
.SH "COPYRIGHT AND LICENCE" |
| 146 |
.IX Header "COPYRIGHT AND LICENCE" |
| 147 |
This software is copyright (c) 2006 by יובל קוג'מן (Yuval Kogman) <[email protected]>. |
| 148 |
.PP |
| 149 |
This is free software; you can redistribute it and/or modify it under |
| 150 |
the same terms as the Perl 5 programming language system itself. |