line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file was autogenerated. |
2
|
2
|
|
|
2
|
|
226628
|
use 5.008001; |
|
2
|
|
|
|
|
13
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
9
|
no warnings qw( void once ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
6
|
2
|
|
|
2
|
|
431
|
use Hydrogen (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
147
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Hydrogen::Hash; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
11
|
|
|
|
|
|
|
our $VERSION = '0.017'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Hydrogen::Hash - a standard library for hashes |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This documentation is for Hydrogen::Hash 0.017, |
20
|
|
|
|
|
|
|
which is based on Sub::HandlesVia::HandlerLibrary::Hash 0.038. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 FUNCTIONS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Each function expects a hash as its first argument. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
The functions use prototypes, so you don't have to pass a reference. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
10
|
use Exporter::Shiny qw( |
33
|
|
|
|
|
|
|
accessor |
34
|
|
|
|
|
|
|
all |
35
|
|
|
|
|
|
|
clear |
36
|
|
|
|
|
|
|
count |
37
|
|
|
|
|
|
|
defined |
38
|
|
|
|
|
|
|
delete |
39
|
|
|
|
|
|
|
delete_where |
40
|
|
|
|
|
|
|
elements |
41
|
|
|
|
|
|
|
exists |
42
|
|
|
|
|
|
|
for_each_key |
43
|
|
|
|
|
|
|
for_each_pair |
44
|
|
|
|
|
|
|
for_each_value |
45
|
|
|
|
|
|
|
get |
46
|
|
|
|
|
|
|
is_empty |
47
|
|
|
|
|
|
|
keys |
48
|
|
|
|
|
|
|
kv |
49
|
|
|
|
|
|
|
reset |
50
|
|
|
|
|
|
|
set |
51
|
|
|
|
|
|
|
shallow_clone |
52
|
|
|
|
|
|
|
sorted_keys |
53
|
|
|
|
|
|
|
values |
54
|
2
|
|
|
2
|
|
13
|
); |
|
2
|
|
|
|
|
4
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 C<< accessor( %hash, $key, $value? ) >> |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Additional arguments: B<< Str >>, B<< Optional[Any] >>. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Acts like C if given just a key, or C if given a key and a value. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
my $__signature; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub accessor (\%$;$) { |
68
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
71
|
|
|
|
|
|
|
$__signature ||= sub { |
72
|
0
|
|
|
0
|
|
0
|
my ( %tmp, $tmp ); |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
0
|
@_ >= 2 && @_ <= 3 |
75
|
|
|
|
|
|
|
or Hydrogen::croak( |
76
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
77
|
|
|
|
|
|
|
"accessor", scalar(@_), "expected exactly 2 parameters" ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
80
|
0
|
0
|
|
|
|
0
|
( ref( $_[0] ) eq 'HASH' ) |
81
|
|
|
|
|
|
|
or Hydrogen::croak( |
82
|
|
|
|
|
|
|
"Type check failed in signature for accessor: %s should be %s", |
83
|
|
|
|
|
|
|
"\$_[0]", "HashRef" |
84
|
|
|
|
|
|
|
); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
87
|
0
|
0
|
|
|
|
0
|
do { |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
90
|
0
|
0
|
|
|
|
0
|
defined( $_[1] ) and do { |
91
|
0
|
0
|
|
|
|
0
|
ref( \$_[1] ) eq 'SCALAR' |
92
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
or Hydrogen::croak( |
96
|
|
|
|
|
|
|
"Type check failed in signature for accessor: %s should be %s", |
97
|
|
|
|
|
|
|
"\$_[1]", "Str" |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Parameter $_[2] (type: Optional[Any]) |
101
|
0
|
0
|
|
|
|
0
|
$#_ >= 2 |
102
|
|
|
|
|
|
|
or return (@_); |
103
|
0
|
|
|
|
|
0
|
( !!1 ) |
104
|
|
|
|
|
|
|
or Hydrogen::croak( |
105
|
|
|
|
|
|
|
"Type check failed in signature for accessor: %s should be %s", |
106
|
|
|
|
|
|
|
"\$_[2]", "Optional[Any]" |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
0
|
(@_); |
110
|
0
|
|
0
|
|
|
0
|
}; |
111
|
0
|
|
|
|
|
0
|
@_ = &$__signature; |
112
|
0
|
|
|
|
|
0
|
1; |
113
|
|
|
|
|
|
|
( ( @_ - 1 ) == 1 ) |
114
|
|
|
|
|
|
|
? ($$__REF__)->{ $_[1] } |
115
|
0
|
0
|
|
|
|
0
|
: ( ($$__REF__)->{ $_[1] } = $_[2] ); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 C<< all( %hash ) >> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the hash in list context. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub all (\%) { |
126
|
1
|
|
|
1
|
1
|
9200
|
my $__REF__ = \$_[0]; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
129
|
1
|
50
|
|
|
|
6
|
@_ == 1 |
130
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for all; usage: " |
131
|
|
|
|
|
|
|
. "Hydrogen::Hash::all( %hash )" ); |
132
|
1
|
|
|
|
|
2
|
%{$$__REF__}; |
|
1
|
|
|
|
|
6
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 C<< clear( %hash ) >> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Empties the hash. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub clear (\%) { |
142
|
1
|
|
|
1
|
1
|
3432
|
my $__REF__ = \$_[0]; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
145
|
1
|
50
|
|
|
|
6
|
@_ == 1 |
146
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for clear; usage: " |
147
|
|
|
|
|
|
|
. "Hydrogen::Hash::clear( %hash )" ); |
148
|
1
|
|
|
|
|
2
|
1; |
149
|
1
|
|
|
|
|
2
|
%{$$__REF__} = (); |
|
1
|
|
|
|
|
4
|
|
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 C<< count( %hash ) >> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
Returns the number of keys in the hash. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub count (\%) { |
159
|
1
|
|
|
1
|
1
|
3083
|
my $__REF__ = \$_[0]; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
162
|
1
|
50
|
|
|
|
5
|
@_ == 1 |
163
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for count; usage: " |
164
|
|
|
|
|
|
|
. "Hydrogen::Hash::count( %hash )" ); |
165
|
1
|
|
|
|
|
2
|
scalar keys %{$$__REF__}; |
|
1
|
|
|
|
|
8
|
|
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 C<< defined( %hash, $key ) >> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Indicates whether a value exists and is defined in the hashref by its key. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub defined (\%$) { |
177
|
1
|
|
|
1
|
1
|
3210
|
my $__REF__ = \$_[0]; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
180
|
1
|
|
|
|
|
2
|
@_ = do { |
181
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
182
|
|
|
|
|
|
|
|
183
|
1
|
50
|
|
|
|
6
|
@_ == 2 |
184
|
|
|
|
|
|
|
or Hydrogen::croak( |
185
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
186
|
|
|
|
|
|
|
"defined", scalar(@_), "expected exactly 2 parameters" ); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
189
|
1
|
50
|
|
|
|
5
|
( ref( $_[0] ) eq 'HASH' ) |
190
|
|
|
|
|
|
|
or Hydrogen::croak( |
191
|
|
|
|
|
|
|
"Type check failed in signature for defined: %s should be %s", |
192
|
|
|
|
|
|
|
"\$_[0]", "HashRef" ); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
195
|
1
|
50
|
|
|
|
2
|
do { |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
198
|
1
|
50
|
|
|
|
7
|
defined( $_[1] ) and do { |
199
|
1
|
50
|
|
|
|
7
|
ref( \$_[1] ) eq 'SCALAR' |
200
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
or Hydrogen::croak( |
204
|
|
|
|
|
|
|
"Type check failed in signature for defined: %s should be %s", |
205
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
206
|
|
|
|
|
|
|
|
207
|
1
|
|
|
|
|
5
|
(@_); |
208
|
|
|
|
|
|
|
}; |
209
|
1
|
|
|
|
|
7
|
defined( ($$__REF__)->{ $_[1] } ); |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 C<< delete( %hash, $key ) >> |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Removes a value from the hashref by its key. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=cut |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub delete (\%$;@) { |
219
|
1
|
|
|
1
|
1
|
2820
|
my $__REF__ = \$_[0]; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
222
|
1
|
50
|
|
|
|
5
|
@_ >= 2 |
223
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for delete; usage: " |
224
|
|
|
|
|
|
|
. "Hydrogen::Hash::delete( %hash, \$key )" ); |
225
|
1
|
|
|
|
|
2
|
1; |
226
|
1
|
|
|
|
|
5
|
delete( @{$$__REF__}{ @_[ 1 .. $#_ ] } ); |
|
1
|
|
|
|
|
4
|
|
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 C<< delete_where( %hash, $match ) >> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Additional arguments: B<< CodeRef|RegexpRef >>. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Removes values from the hashref by matching keys against a coderef or regexp. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
sub delete_where (\%$;@) { |
238
|
2
|
|
|
2
|
1
|
3245
|
my $__REF__ = \$_[0]; |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
241
|
2
|
|
|
|
|
4
|
@_ = do { |
242
|
2
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
243
|
|
|
|
|
|
|
|
244
|
2
|
50
|
|
|
|
8
|
@_ == 2 |
245
|
|
|
|
|
|
|
or Hydrogen::croak( |
246
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
247
|
|
|
|
|
|
|
"delete_where", scalar(@_), "expected exactly 2 parameters" ); |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
250
|
2
|
50
|
|
|
|
6
|
( ref( $_[0] ) eq 'HASH' ) |
251
|
|
|
|
|
|
|
or Hydrogen::croak( |
252
|
|
|
|
|
|
|
"Type check failed in signature for delete_where: %s should be %s", |
253
|
|
|
|
|
|
|
"\$_[0]", "HashRef" |
254
|
|
|
|
|
|
|
); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
# Parameter $_[1] (type: CodeRef|RegexpRef) |
257
|
2
|
50
|
|
|
|
4
|
do { |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
260
|
|
|
|
|
|
|
( |
261
|
|
|
|
|
|
|
( ref( $_[1] ) eq 'CODE' ) or ( |
262
|
2
|
100
|
|
|
|
9
|
do { |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
265
|
2
|
|
|
2
|
|
1959
|
use Scalar::Util (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
46
|
|
266
|
2
|
|
|
2
|
|
10
|
use re (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
4021
|
|
267
|
1
|
50
|
0
|
|
|
11
|
ref( $_[1] ) && !!re::is_regexp( $_[1] ) |
|
|
|
33
|
|
|
|
|
268
|
|
|
|
|
|
|
or Scalar::Util::blessed( $_[1] ) |
269
|
|
|
|
|
|
|
&& $_[1]->isa('Regexp'); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
) |
272
|
|
|
|
|
|
|
); |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
or Hydrogen::croak( |
275
|
|
|
|
|
|
|
"Type check failed in signature for delete_where: %s should be %s", |
276
|
|
|
|
|
|
|
"\$_[1]", "CodeRef|RegexpRef" |
277
|
|
|
|
|
|
|
); |
278
|
|
|
|
|
|
|
|
279
|
2
|
|
|
|
|
7
|
(@_); |
280
|
|
|
|
|
|
|
}; |
281
|
2
|
|
|
|
|
4
|
my %shv_tmp = %{$$__REF__}; |
|
2
|
|
|
|
|
8
|
|
282
|
2
|
|
|
|
|
4
|
my $shv_match = $_[1]; |
283
|
2
|
100
|
|
|
|
43
|
my @shv_keys = |
284
|
|
|
|
|
|
|
( "CODE" eq ref $shv_match ) |
285
|
|
|
|
|
|
|
? grep( $shv_match->($_), keys %shv_tmp ) |
286
|
|
|
|
|
|
|
: grep( /$shv_match/, keys %shv_tmp ); |
287
|
2
|
|
|
|
|
17
|
my @shv_return = delete @shv_tmp{@shv_keys}; |
288
|
|
|
|
|
|
|
( |
289
|
2
|
|
|
|
|
6
|
%{ $_[0] } = %{ |
290
|
2
|
|
|
|
|
4
|
+do { |
|
2
|
|
|
|
|
3
|
|
291
|
2
|
|
|
|
|
4
|
my $shv_final_unchecked = \%shv_tmp; |
292
|
2
|
|
|
|
|
4
|
do { |
293
|
2
|
50
|
|
|
|
7
|
( ref($shv_final_unchecked) eq 'HASH' ) |
294
|
|
|
|
|
|
|
or Hydrogen::croak( |
295
|
|
|
|
|
|
|
"Type check failed for delete_where: expected %s, got value %s", |
296
|
|
|
|
|
|
|
"HashRef", $shv_final_unchecked |
297
|
|
|
|
|
|
|
); |
298
|
2
|
|
|
|
|
5
|
$shv_final_unchecked; |
299
|
|
|
|
|
|
|
}; |
300
|
|
|
|
|
|
|
} |
301
|
|
|
|
|
|
|
} |
302
|
|
|
|
|
|
|
); |
303
|
2
|
50
|
|
|
|
9
|
wantarray ? @shv_return : $shv_return[-1]; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=head2 C<< elements( %hash ) >> |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Returns the hash in list context. |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=cut |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub elements (\%) { |
313
|
1
|
|
|
1
|
1
|
3137
|
my $__REF__ = \$_[0]; |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
316
|
1
|
50
|
|
|
|
5
|
@_ == 1 |
317
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for elements; usage: " |
318
|
|
|
|
|
|
|
. "Hydrogen::Hash::elements( %hash )" ); |
319
|
1
|
|
|
|
|
2
|
%{$$__REF__}; |
|
1
|
|
|
|
|
6
|
|
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=head2 C<< exists( %hash, $key ) >> |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
Additional arguments: B<< Str >>. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Indicates whether a value exists in the hashref by its key. |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=cut |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub exists (\%$) { |
331
|
2
|
|
|
2
|
1
|
2251
|
my $__REF__ = \$_[0]; |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
334
|
2
|
|
|
|
|
4
|
@_ = do { |
335
|
2
|
|
|
|
|
4
|
my ( %tmp, $tmp ); |
336
|
|
|
|
|
|
|
|
337
|
2
|
50
|
|
|
|
7
|
@_ == 2 |
338
|
|
|
|
|
|
|
or Hydrogen::croak( |
339
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
340
|
|
|
|
|
|
|
"exists", scalar(@_), "expected exactly 2 parameters" ); |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
343
|
2
|
50
|
|
|
|
7
|
( ref( $_[0] ) eq 'HASH' ) |
344
|
|
|
|
|
|
|
or Hydrogen::croak( |
345
|
|
|
|
|
|
|
"Type check failed in signature for exists: %s should be %s", |
346
|
|
|
|
|
|
|
"\$_[0]", "HashRef" ); |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# Parameter $_[1] (type: Str) |
349
|
2
|
50
|
|
|
|
5
|
do { |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
352
|
2
|
50
|
|
|
|
6
|
defined( $_[1] ) and do { |
353
|
2
|
50
|
|
|
|
15
|
ref( \$_[1] ) eq 'SCALAR' |
354
|
|
|
|
|
|
|
or ref( \( my $val = $_[1] ) ) eq 'SCALAR'; |
355
|
|
|
|
|
|
|
} |
356
|
|
|
|
|
|
|
} |
357
|
|
|
|
|
|
|
or Hydrogen::croak( |
358
|
|
|
|
|
|
|
"Type check failed in signature for exists: %s should be %s", |
359
|
|
|
|
|
|
|
"\$_[1]", "Str" ); |
360
|
|
|
|
|
|
|
|
361
|
2
|
|
|
|
|
8
|
(@_); |
362
|
|
|
|
|
|
|
}; |
363
|
2
|
|
|
|
|
11
|
defined( ($$__REF__)->{ $_[1] } ); |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head2 C<< for_each_key( %hash, $coderef ) >> |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
Additional arguments: B<< CodeRef >>. |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
Function which calls the coderef for each key in the hash, passing just the key to the coderef. |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
=cut |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
sub for_each_key (\%$) { |
375
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
378
|
0
|
|
|
|
|
0
|
@_ = do { |
379
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
380
|
|
|
|
|
|
|
|
381
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
382
|
|
|
|
|
|
|
or Hydrogen::croak( |
383
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
384
|
|
|
|
|
|
|
"for_each_key", scalar(@_), "expected exactly 2 parameters" ); |
385
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
387
|
0
|
0
|
|
|
|
0
|
( ref( $_[0] ) eq 'HASH' ) |
388
|
|
|
|
|
|
|
or Hydrogen::croak( |
389
|
|
|
|
|
|
|
"Type check failed in signature for for_each_key: %s should be %s", |
390
|
|
|
|
|
|
|
"\$_[0]", "HashRef" |
391
|
|
|
|
|
|
|
); |
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
# Parameter $_[1] (type: CodeRef) |
394
|
0
|
0
|
|
|
|
0
|
( ref( $_[1] ) eq 'CODE' ) |
395
|
|
|
|
|
|
|
or Hydrogen::croak( |
396
|
|
|
|
|
|
|
"Type check failed in signature for for_each_key: %s should be %s", |
397
|
|
|
|
|
|
|
"\$_[1]", "CodeRef" |
398
|
|
|
|
|
|
|
); |
399
|
|
|
|
|
|
|
|
400
|
0
|
|
|
|
|
0
|
(@_); |
401
|
|
|
|
|
|
|
}; |
402
|
0
|
|
|
|
|
0
|
for my $shv_key ( keys %{$$__REF__} ) { &{ $_[1] }($shv_key) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
403
|
0
|
|
|
|
|
0
|
$__REF__; |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
=head2 C<< for_each_pair( %hash, $coderef ) >> |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
Additional arguments: B<< CodeRef >>. |
409
|
|
|
|
|
|
|
|
410
|
|
|
|
|
|
|
Function which calls the coderef for each key in the hash, passing the key and value to the coderef. |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=cut |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
sub for_each_pair (\%$) { |
415
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
416
|
|
|
|
|
|
|
|
417
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
418
|
0
|
|
|
|
|
0
|
@_ = do { |
419
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
420
|
|
|
|
|
|
|
|
421
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
422
|
|
|
|
|
|
|
or Hydrogen::croak( |
423
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
424
|
|
|
|
|
|
|
"for_each_pair", scalar(@_), "expected exactly 2 parameters" ); |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
427
|
0
|
0
|
|
|
|
0
|
( ref( $_[0] ) eq 'HASH' ) |
428
|
|
|
|
|
|
|
or Hydrogen::croak( |
429
|
|
|
|
|
|
|
"Type check failed in signature for for_each_pair: %s should be %s", |
430
|
|
|
|
|
|
|
"\$_[0]", "HashRef" |
431
|
|
|
|
|
|
|
); |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# Parameter $_[1] (type: CodeRef) |
434
|
0
|
0
|
|
|
|
0
|
( ref( $_[1] ) eq 'CODE' ) |
435
|
|
|
|
|
|
|
or Hydrogen::croak( |
436
|
|
|
|
|
|
|
"Type check failed in signature for for_each_pair: %s should be %s", |
437
|
|
|
|
|
|
|
"\$_[1]", "CodeRef" |
438
|
|
|
|
|
|
|
); |
439
|
|
|
|
|
|
|
|
440
|
0
|
|
|
|
|
0
|
(@_); |
441
|
|
|
|
|
|
|
}; |
442
|
0
|
|
|
|
|
0
|
while ( my ( $shv_key, $shv_value ) = each %{$$__REF__} ) { |
|
0
|
|
|
|
|
0
|
|
443
|
0
|
|
|
|
|
0
|
&{ $_[1] }( $shv_key, $shv_value ); |
|
0
|
|
|
|
|
0
|
|
444
|
|
|
|
|
|
|
}; |
445
|
0
|
|
|
|
|
0
|
$__REF__; |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
=head2 C<< for_each_value( %hash, $coderef ) >> |
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
Additional arguments: B<< CodeRef >>. |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
Function which calls the coderef for each value in the hash, passing just the value to the coderef. |
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
=cut |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
sub for_each_value (\%$) { |
457
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
460
|
0
|
|
|
|
|
0
|
@_ = do { |
461
|
0
|
|
|
|
|
0
|
my ( %tmp, $tmp ); |
462
|
|
|
|
|
|
|
|
463
|
0
|
0
|
|
|
|
0
|
@_ == 2 |
464
|
|
|
|
|
|
|
or Hydrogen::croak( |
465
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
466
|
|
|
|
|
|
|
"for_each_value", scalar(@_), "expected exactly 2 parameters" ); |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
# Parameter $_[0] (type: HashRef) |
469
|
0
|
0
|
|
|
|
0
|
( ref( $_[0] ) eq 'HASH' ) |
470
|
|
|
|
|
|
|
or Hydrogen::croak( |
471
|
|
|
|
|
|
|
"Type check failed in signature for for_each_value: %s should be %s", |
472
|
|
|
|
|
|
|
"\$_[0]", "HashRef" |
473
|
|
|
|
|
|
|
); |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
# Parameter $_[1] (type: CodeRef) |
476
|
0
|
0
|
|
|
|
0
|
( ref( $_[1] ) eq 'CODE' ) |
477
|
|
|
|
|
|
|
or Hydrogen::croak( |
478
|
|
|
|
|
|
|
"Type check failed in signature for for_each_value: %s should be %s", |
479
|
|
|
|
|
|
|
"\$_[1]", "CodeRef" |
480
|
|
|
|
|
|
|
); |
481
|
|
|
|
|
|
|
|
482
|
0
|
|
|
|
|
0
|
(@_); |
483
|
|
|
|
|
|
|
}; |
484
|
0
|
|
|
|
|
0
|
for my $shv_value ( values %{$$__REF__} ) { &{ $_[1] }($shv_value) }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
485
|
0
|
|
|
|
|
0
|
$__REF__; |
486
|
|
|
|
|
|
|
} |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=head2 C<< get( %hash, $key ) >> |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
Returns a value from the hashref by its key. |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
=cut |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
sub get (\%$;@) { |
495
|
1
|
|
|
1
|
1
|
8113
|
my $__REF__ = \$_[0]; |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
498
|
1
|
50
|
|
|
|
6
|
@_ >= 2 |
499
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for get; usage: " |
500
|
|
|
|
|
|
|
. "Hydrogen::Hash::get( %hash, \$key )" ); |
501
|
1
|
50
|
|
|
|
9
|
( @_ - 1 ) > 1 ? @{$$__REF__}{ @_[ 1 .. $#_ ] } : ($$__REF__)->{ $_[1] }; |
|
0
|
|
|
|
|
0
|
|
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=head2 C<< is_empty( %hash ) >> |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
Returns true iff there are no keys in the hash. |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=cut |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
sub is_empty (\%) { |
511
|
2
|
|
|
2
|
1
|
3309
|
my $__REF__ = \$_[0]; |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
514
|
2
|
50
|
|
|
|
9
|
@_ == 1 |
515
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for is_empty; usage: " |
516
|
|
|
|
|
|
|
. "Hydrogen::Hash::is_empty( %hash )" ); |
517
|
2
|
|
|
|
|
4
|
!scalar keys %{$$__REF__}; |
|
2
|
|
|
|
|
9
|
|
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=head2 C<< keys( %hash ) >> |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Returns the list of keys in the hash. |
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=cut |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
sub keys (\%) { |
527
|
1
|
|
|
1
|
1
|
3575
|
my $__REF__ = \$_[0]; |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
530
|
1
|
50
|
|
|
|
5
|
@_ == 1 |
531
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for keys; usage: " |
532
|
|
|
|
|
|
|
. "Hydrogen::Hash::keys( %hash )" ); |
533
|
1
|
|
|
|
|
2
|
keys %{$$__REF__}; |
|
1
|
|
|
|
|
5
|
|
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head2 C<< kv( %hash ) >> |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
Returns a list of arrayrefs, where each arrayref is a key-value pair. |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=cut |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
sub kv (\%) { |
543
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
546
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
547
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for kv; usage: " |
548
|
|
|
|
|
|
|
. "Hydrogen::Hash::kv( %hash )" ); |
549
|
0
|
|
|
|
|
0
|
map [ $_ => ($$__REF__)->{$_} ], keys %{$$__REF__}; |
|
0
|
|
|
|
|
0
|
|
550
|
|
|
|
|
|
|
} |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
=head2 C<< reset( %hash ) >> |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
Resets the original value to its default value, or an empty hashref if it has no default. |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=cut |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
sub reset (\%) { |
559
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
562
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
563
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for reset; usage: " |
564
|
|
|
|
|
|
|
. "Hydrogen::Hash::reset( %hash )" ); |
565
|
|
|
|
|
|
|
( |
566
|
0
|
|
|
|
|
0
|
%{ $_[0] } = %{ |
567
|
0
|
|
|
|
|
0
|
+do { |
|
0
|
|
|
|
|
0
|
|
568
|
0
|
|
|
|
|
0
|
my $shv_final_unchecked = {}; |
569
|
0
|
|
|
|
|
0
|
do { |
570
|
0
|
0
|
|
|
|
0
|
( ref($shv_final_unchecked) eq 'HASH' ) |
571
|
|
|
|
|
|
|
or Hydrogen::croak( |
572
|
|
|
|
|
|
|
"Type check failed for reset: expected %s, got value %s", |
573
|
|
|
|
|
|
|
"HashRef", $shv_final_unchecked |
574
|
|
|
|
|
|
|
); |
575
|
0
|
|
|
|
|
0
|
$shv_final_unchecked; |
576
|
|
|
|
|
|
|
}; |
577
|
|
|
|
|
|
|
} |
578
|
|
|
|
|
|
|
} |
579
|
|
|
|
|
|
|
); |
580
|
|
|
|
|
|
|
} |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
=head2 C<< set( %hash, $key, $value, ... ) >> |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
Given a key and value, adds the key to the hashref with the given value. |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
=cut |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
sub set (\%$$;@) { |
589
|
1
|
|
|
1
|
1
|
9024
|
my $__REF__ = \$_[0]; |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
592
|
1
|
50
|
|
|
|
6
|
@_ >= 3 |
593
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for set; usage: " |
594
|
|
|
|
|
|
|
. "Hydrogen::Hash::set( %hash, \$key, \$value, ... )" ); |
595
|
1
|
|
|
|
|
6
|
my (@shv_params) = @_[ 1 .. $#_ ]; |
596
|
1
|
50
|
|
|
|
6
|
scalar(@shv_params) % 2 |
597
|
|
|
|
|
|
|
and Hydrogen::croak( |
598
|
|
|
|
|
|
|
"Wrong number of parameters; expected even-sized list of keys and values" |
599
|
|
|
|
|
|
|
); |
600
|
1
|
|
|
|
|
7
|
my (@shv_keys_idx) = grep( !( $_ % 2 ), 0 .. $#shv_params ); |
601
|
1
|
|
|
|
|
5
|
my (@shv_values_idx) = grep( ( $_ % 2 ), 0 .. $#shv_params ); |
602
|
1
|
50
|
|
|
|
6
|
grep( !defined, @shv_params[@shv_keys_idx] ) |
603
|
|
|
|
|
|
|
and Hydrogen::croak( |
604
|
|
|
|
|
|
|
"Undef did not pass type constraint; keys must be defined"); |
605
|
|
|
|
|
|
|
|
606
|
1
|
|
|
|
|
3
|
for my $shv_tmp (@shv_keys_idx) { |
607
|
2
|
|
|
|
|
4
|
do { |
608
|
2
|
50
|
|
|
|
3
|
do { |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
611
|
2
|
50
|
|
|
|
7
|
defined( $shv_params[$shv_tmp] ) and do { |
612
|
2
|
50
|
|
|
|
13
|
ref( \$shv_params[$shv_tmp] ) eq 'SCALAR' |
613
|
|
|
|
|
|
|
or ref( \( my $val = $shv_params[$shv_tmp] ) ) eq 'SCALAR'; |
614
|
|
|
|
|
|
|
} |
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
or Hydrogen::croak( |
617
|
|
|
|
|
|
|
"Type check failed for set: expected %s, got value %s", |
618
|
|
|
|
|
|
|
"Str", $shv_params[$shv_tmp] ); |
619
|
2
|
|
|
|
|
5
|
$shv_params[$shv_tmp]; |
620
|
|
|
|
|
|
|
}; |
621
|
|
|
|
|
|
|
}; |
622
|
1
|
|
|
|
|
3
|
@{$$__REF__}{ @shv_params[@shv_keys_idx] } = @shv_params[@shv_values_idx]; |
|
1
|
|
|
|
|
4
|
|
623
|
|
|
|
|
|
|
wantarray |
624
|
0
|
|
|
|
|
0
|
? @{$$__REF__}{ @shv_params[@shv_keys_idx] } |
625
|
1
|
50
|
|
|
|
6
|
: ($$__REF__)->{ $shv_params[ $shv_keys_idx[0] ] }; |
626
|
|
|
|
|
|
|
} |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
=head2 C<< shallow_clone( %hash ) >> |
629
|
|
|
|
|
|
|
|
630
|
|
|
|
|
|
|
Creates a new hashref with the same keys and values as the original. |
631
|
|
|
|
|
|
|
|
632
|
|
|
|
|
|
|
=cut |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
sub shallow_clone (\%) { |
635
|
0
|
|
|
0
|
1
|
0
|
my $__REF__ = \$_[0]; |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
638
|
0
|
0
|
|
|
|
0
|
@_ == 1 |
639
|
|
|
|
|
|
|
or |
640
|
|
|
|
|
|
|
Hydrogen::croak( "Wrong number of parameters for shallow_clone; usage: " |
641
|
|
|
|
|
|
|
. "Hydrogen::Hash::shallow_clone( %hash )" ); |
642
|
0
|
|
|
|
|
0
|
+{ %{$$__REF__} }; |
|
0
|
|
|
|
|
0
|
|
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
=head2 C<< sorted_keys( %hash ) >> |
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
Returns an alphabetically sorted list of keys in the hash. |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
=cut |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
sub sorted_keys (\%) { |
652
|
1
|
|
|
1
|
1
|
7093
|
my $__REF__ = \$_[0]; |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
655
|
1
|
50
|
|
|
|
6
|
@_ == 1 |
656
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for sorted_keys; usage: " |
657
|
|
|
|
|
|
|
. "Hydrogen::Hash::sorted_keys( %hash )" ); |
658
|
1
|
|
|
|
|
3
|
sort( keys %{$$__REF__} ); |
|
1
|
|
|
|
|
9
|
|
659
|
|
|
|
|
|
|
} |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
=head2 C<< values( %hash ) >> |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
Returns the list of values in the hash. |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
=cut |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
sub values (\%) { |
668
|
1
|
|
|
1
|
1
|
8209
|
my $__REF__ = \$_[0]; |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
package Hydrogen::Hash::__SANDBOX__; |
671
|
1
|
50
|
|
|
|
7
|
@_ == 1 |
672
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for values; usage: " |
673
|
|
|
|
|
|
|
. "Hydrogen::Hash::values( %hash )" ); |
674
|
1
|
|
|
|
|
2
|
values %{$$__REF__}; |
|
1
|
|
|
|
|
5
|
|
675
|
|
|
|
|
|
|
} |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
1; |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head1 EXPORT |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
No functions are exported by this module by default. To import them all (this is usually a bad idea), use: |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
use Hydrogen::Hash -all; |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
To import a particular function, use: |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
use Hydrogen::Hash 'clear'; |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
To rename functions: |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
use Hydrogen::Hash 'clear' => { -as => 'myfunc' }; |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
On Perl 5.37.2+, you can import lexically: |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
use Hydrogen::Hash -lexical, 'clear'; |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
See L for more hints on importing. |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
=head1 BUGS |
700
|
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
Please report any bugs to |
702
|
|
|
|
|
|
|
L. |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
=head1 SEE ALSO |
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
L, |
707
|
|
|
|
|
|
|
L, |
708
|
|
|
|
|
|
|
L, |
709
|
|
|
|
|
|
|
L, |
710
|
|
|
|
|
|
|
L. |
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
=head1 AUTHOR |
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
Toby Inkster Etobyink@cpan.orgE. |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Toby Inkster. |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
721
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
726
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
727
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
728
|
|
|
|
|
|
|
|