.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 "2021-09-24" "perl v5.32.1" "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 "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 \s-1TIEHASH\s0 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 "RELIC SUPPORT" .IX Header "RELIC SUPPORT" This version of Tie::RefHash seems to no longer work with 5.004. This has not been throughly investigated. Patches welcome ;\-) .SH "LICENSE" .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself .SH "MAINTAINER" .IX Header "MAINTAINER" Yuval Kogman .SH "AUTHOR" .IX Header "AUTHOR" Gurusamy Sarathy gsar@activestate.com .PP \&'Nestable' by Ed Avis ed@membled.com .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBperl\fR\|(1), \fBperlfunc\fR\|(1), \fBperltie\fR\|(1)