Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Tie::Hash.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "Tie::Hash 3"
132.TH Tie::Hash 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
133.SH "NAME"
134Tie::Hash, Tie::StdHash, Tie::ExtraHash \- base class definitions for tied hashes
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 2
138\& package NewHash;
139\& require Tie::Hash;
140.Ve
141.PP
142.Vb 1
143\& @ISA = (Tie::Hash);
144.Ve
145.PP
146.Vb 2
147\& sub DELETE { ... } # Provides needed method
148\& sub CLEAR { ... } # Overrides inherited method
149.Ve
150.PP
151.Vb 2
152\& package NewStdHash;
153\& require Tie::Hash;
154.Ve
155.PP
156.Vb 1
157\& @ISA = (Tie::StdHash);
158.Ve
159.PP
160.Vb 4
161\& # All methods provided by default, define only those needing overrides
162\& # Accessors access the storage in %{$_[0]};
163\& # TIEHANDLE should return a reference to the actual storage
164\& sub DELETE { ... }
165.Ve
166.PP
167.Vb 2
168\& package NewExtraHash;
169\& require Tie::Hash;
170.Ve
171.PP
172.Vb 1
173\& @ISA = (Tie::ExtraHash);
174.Ve
175.PP
176.Vb 7
177\& # All methods provided by default, define only those needing overrides
178\& # Accessors access the storage in %{$_[0][0]};
179\& # TIEHANDLE should return an array reference with the first element being
180\& # the reference to the actual storage
181\& sub DELETE {
182\& $_[0][1]->('del', $_[0][0], $_[1]); # Call the report writer
183\& delete $_[0][0]->{$_[1]}; # $_[0]->SUPER::DELETE($_[1]) }
184.Ve
185.PP
186.Vb 1
187\& package main;
188.Ve
189.PP
190.Vb 4
191\& tie %new_hash, 'NewHash';
192\& tie %new_std_hash, 'NewStdHash';
193\& tie %new_extra_hash, 'NewExtraHash',
194\& sub {warn "Doing \eU$_[1]\eE of $_[2].\en"};
195.Ve
196.SH "DESCRIPTION"
197.IX Header "DESCRIPTION"
198This module provides some skeletal methods for hash-tying classes. See
199perltie for a list of the functions required in order to tie a hash
200to a package. The basic \fBTie::Hash\fR package provides a \f(CW\*(C`new\*(C'\fR method, as well
201as methods \f(CW\*(C`TIEHASH\*(C'\fR, \f(CW\*(C`EXISTS\*(C'\fR and \f(CW\*(C`CLEAR\*(C'\fR. The \fBTie::StdHash\fR and
202\&\fBTie::ExtraHash\fR packages
203provide most methods for hashes described in perltie (the exceptions
204are \f(CW\*(C`UNTIE\*(C'\fR and \f(CW\*(C`DESTROY\*(C'\fR). They cause tied hashes to behave exactly like standard hashes,
205and allow for selective overwriting of methods. \fBTie::Hash\fR grandfathers the
206\&\f(CW\*(C`new\*(C'\fR method: it is used if \f(CW\*(C`TIEHASH\*(C'\fR is not defined
207in the case a class forgets to include a \f(CW\*(C`TIEHASH\*(C'\fR method.
208.PP
209For developers wishing to write their own tied hashes, the required methods
210are briefly defined below. See the perltie section for more detailed
211descriptive, as well as example code:
212.IP "\s-1TIEHASH\s0 classname, \s-1LIST\s0" 4
213.IX Item "TIEHASH classname, LIST"
214The method invoked by the command \f(CW\*(C`tie %hash, classname\*(C'\fR. Associates a new
215hash instance with the specified class. \f(CW\*(C`LIST\*(C'\fR would represent additional
216arguments (along the lines of AnyDBM_File and compatriots) needed to
217complete the association.
218.IP "\s-1STORE\s0 this, key, value" 4
219.IX Item "STORE this, key, value"
220Store datum \fIvalue\fR into \fIkey\fR for the tied hash \fIthis\fR.
221.IP "\s-1FETCH\s0 this, key" 4
222.IX Item "FETCH this, key"
223Retrieve the datum in \fIkey\fR for the tied hash \fIthis\fR.
224.IP "\s-1FIRSTKEY\s0 this" 4
225.IX Item "FIRSTKEY this"
226Return the first key in the hash.
227.IP "\s-1NEXTKEY\s0 this, lastkey" 4
228.IX Item "NEXTKEY this, lastkey"
229Return the next key in the hash.
230.IP "\s-1EXISTS\s0 this, key" 4
231.IX Item "EXISTS this, key"
232Verify that \fIkey\fR exists with the tied hash \fIthis\fR.
233.Sp
234The \fBTie::Hash\fR implementation is a stub that simply croaks.
235.IP "\s-1DELETE\s0 this, key" 4
236.IX Item "DELETE this, key"
237Delete the key \fIkey\fR from the tied hash \fIthis\fR.
238.IP "\s-1CLEAR\s0 this" 4
239.IX Item "CLEAR this"
240Clear all values from the tied hash \fIthis\fR.
241.SH "Inheriting from \fBTie::StdHash\fP"
242.IX Header "Inheriting from Tie::StdHash"
243The accessor methods assume that the actual storage for the data in the tied
244hash is in the hash referenced by \f(CW\*(C`tied(%tiedhash)\*(C'\fR. Thus overwritten
245\&\f(CW\*(C`TIEHANDLE\*(C'\fR method should return a hash reference, and the remaining methods
246should operate on the hash referenced by the first argument:
247.PP
248.Vb 2
249\& package ReportHash;
250\& our @ISA = 'Tie::StdHash';
251.Ve
252.PP
253.Vb 9
254\& sub TIEHASH {
255\& my $storage = bless {}, shift;
256\& warn "New ReportHash created, stored in $storage.\en";
257\& $storage
258\& }
259\& sub STORE {
260\& warn "Storing data with key $_[1] at $_[0].\en";
261\& $_[0]{$_[1]} = $_[2]
262\& }
263.Ve
264.SH "Inheriting from \fBTie::ExtraHash\fP"
265.IX Header "Inheriting from Tie::ExtraHash"
266The accessor methods assume that the actual storage for the data in the tied
267hash is in the hash referenced by \f(CW\*(C`(tied(%tiedhash))[0]\*(C'\fR. Thus overwritten
268\&\f(CW\*(C`TIEHANDLE\*(C'\fR method should return an array reference with the first
269element being a hash reference, and the remaining methods should operate on the
270hash \f(CW\*(C`%{ $_[0]\->[0] }\*(C'\fR:
271.PP
272.Vb 2
273\& package ReportHash;
274\& our @ISA = 'Tie::StdHash';
275.Ve
276.PP
277.Vb 9
278\& sub TIEHASH {
279\& my $storage = bless {}, shift;
280\& warn "New ReportHash created, stored in $storage.\en";
281\& [$storage, @_]
282\& }
283\& sub STORE {
284\& warn "Storing data with key $_[1] at $_[0].\en";
285\& $_[0][0]{$_[1]} = $_[2]
286\& }
287.Ve
288.PP
289The default \f(CW\*(C`TIEHANDLE\*(C'\fR method stores \*(L"extra\*(R" arguments to \fItie()\fR starting
290from offset 1 in the array referenced by \f(CW\*(C`tied(%tiedhash)\*(C'\fR; this is the
291same storage algorithm as in \s-1TIEHASH\s0 subroutine above. Hence, a typical
292package inheriting from \fBTie::ExtraHash\fR does not need to overwrite this
293method.
294.ie n .SH """UNTIE""\fP and \f(CW""DESTROY"""
295.el .SH "\f(CWUNTIE\fP and \f(CWDESTROY\fP"
296.IX Header "UNTIE and DESTROY"
297The methods \f(CW\*(C`UNTIE\*(C'\fR and \f(CW\*(C`DESTROY\*(C'\fR are not defined in \fBTie::Hash\fR,
298\&\fBTie::StdHash\fR, or \fBTie::ExtraHash\fR. Tied hashes do not require
299presense of these methods, but if defined, the methods will be called in
300proper time, see perltie.
301.PP
302If needed, these methods should be defined by the package inheriting from
303\&\fBTie::Hash\fR, \fBTie::StdHash\fR, or \fBTie::ExtraHash\fR.
304.SH "MORE INFORMATION"
305.IX Header "MORE INFORMATION"
306The packages relating to various DBM-related implementations (\fIDB_File\fR,
307\&\fINDBM_File\fR, etc.) show examples of general tied hashes, as does the
308Config module. While these do not utilize \fBTie::Hash\fR, they serve as
309good working examples.