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