1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
.\" -*- 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-02-11 "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 <https://rt.cpan.org/Public/Dist/Display.html?Name=Tie-RefHash>
(or bug\-Tie\-RefHash@rt.cpan.org <mailto:bug-Tie-RefHash@rt.cpan.org>).
.SH AUTHORS
.IX Header "AUTHORS"
Gurusamy Sarathy <gsar@activestate.com>
.PP
Tie::RefHash::Nestable by Ed Avis <ed@membled.com>
.SH CONTRIBUTORS
.IX Header "CONTRIBUTORS"
.IP \(bu 4
Yuval Kogman <nothingmuch@woobling.org>
.IP \(bu 4
Karen Etheridge <ether@cpan.org>
.IP \(bu 4
Florian Ragwitz <rafl@debian.org>
.IP \(bu 4
Jerry D. Hedden <jdhedden@cpan.org>
.SH "COPYRIGHT AND LICENCE"
.IX Header "COPYRIGHT AND LICENCE"
This software is copyright (c) 2006 by יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>.
.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.
|