line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# This file was autogenerated. |
2
|
3
|
|
|
3
|
|
221289
|
use 5.008001; |
|
3
|
|
|
|
|
16
|
|
3
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
70
|
|
4
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
76
|
|
5
|
3
|
|
|
3
|
|
15
|
no warnings qw( void once ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
88
|
|
6
|
3
|
|
|
3
|
|
397
|
use Hydrogen (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
169
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Hydrogen::Counter; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
11
|
|
|
|
|
|
|
our $VERSION = '0.020000'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Hydrogen::Counter - a standard library for integer counters |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This documentation is for Hydrogen::Counter 0.020000, |
20
|
|
|
|
|
|
|
which is based on Sub::HandlesVia::HandlerLibrary::Counter 0.046. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 FUNCTIONS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Each function expects an integer as its first argument. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
3
|
|
|
|
|
16
|
use Exporter::Shiny qw( |
31
|
|
|
|
|
|
|
dec |
32
|
|
|
|
|
|
|
inc |
33
|
|
|
|
|
|
|
reset |
34
|
|
|
|
|
|
|
set |
35
|
3
|
|
|
3
|
|
17
|
); |
|
3
|
|
|
|
|
6
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 C<< dec( $counter, $amount? ) >> |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Additional arguments: B<< Optional[Int] >>. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Decrements the counter by C<< $amount >>, or by 1 if no value is given. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=cut |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
my $__signature; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub dec { |
49
|
3
|
|
|
3
|
1
|
8175
|
my $__REF__ = \$_[0]; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
package Hydrogen::Counter::__SANDBOX__; |
52
|
|
|
|
|
|
|
$__signature ||= sub { |
53
|
3
|
|
|
3
|
|
5
|
my ( %tmp, $tmp ); |
54
|
|
|
|
|
|
|
|
55
|
3
|
50
|
33
|
|
|
17
|
@_ >= 1 && @_ <= 2 |
56
|
|
|
|
|
|
|
or Hydrogen::croak( |
57
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
58
|
|
|
|
|
|
|
"dec", scalar(@_), "expected exactly 1 parameters" ); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Parameter $_[0] (type: Int) |
61
|
|
|
|
|
|
|
( |
62
|
3
|
50
|
|
|
|
5
|
do { |
63
|
3
|
|
|
|
|
5
|
my $tmp = $_[0]; |
64
|
3
|
50
|
33
|
|
|
33
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
) |
67
|
|
|
|
|
|
|
or Hydrogen::croak( |
68
|
|
|
|
|
|
|
"Type check failed in signature for dec: %s should be %s", |
69
|
|
|
|
|
|
|
"\$_[0]", "Int" ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Parameter $_[1] (type: Optional[Int]) |
72
|
3
|
100
|
|
|
|
23
|
$#_ >= 1 |
73
|
|
|
|
|
|
|
or return (@_); |
74
|
|
|
|
|
|
|
( |
75
|
1
|
50
|
|
|
|
14
|
do { |
76
|
1
|
|
|
|
|
2
|
my $tmp = $_[1]; |
77
|
1
|
50
|
33
|
|
|
22
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
) |
80
|
|
|
|
|
|
|
or Hydrogen::croak( |
81
|
|
|
|
|
|
|
"Type check failed in signature for dec: %s should be %s", |
82
|
|
|
|
|
|
|
"\$_[1]", "Optional[Int]" ); |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
4
|
(@_); |
85
|
3
|
|
100
|
|
|
18
|
}; |
86
|
3
|
|
|
|
|
10
|
@_ = &$__signature; |
87
|
|
|
|
|
|
|
( |
88
|
3
|
|
|
|
|
7
|
${$__REF__} = do { |
|
3
|
|
|
|
|
8
|
|
89
|
3
|
100
|
|
|
|
13
|
my $shv_final_unchecked = |
90
|
|
|
|
|
|
|
$$__REF__ - ( ( @_ - 1 ) ? $_[1] : 1 ); |
91
|
3
|
|
|
|
|
4
|
do { |
92
|
|
|
|
|
|
|
( |
93
|
3
|
50
|
|
|
|
7
|
do { |
94
|
3
|
|
|
|
|
4
|
my $tmp = $shv_final_unchecked; |
95
|
3
|
50
|
33
|
|
|
33
|
defined($tmp) |
96
|
|
|
|
|
|
|
and !ref($tmp) |
97
|
|
|
|
|
|
|
and $tmp =~ /\A-?[0-9]+\z/; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
) |
100
|
|
|
|
|
|
|
or Hydrogen::croak( |
101
|
|
|
|
|
|
|
"Type check failed for dec: expected %s, got value %s", |
102
|
|
|
|
|
|
|
"Int", $shv_final_unchecked |
103
|
|
|
|
|
|
|
); |
104
|
3
|
|
|
|
|
7
|
$shv_final_unchecked; |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 C<< inc( $counter, $amount? ) >> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Additional arguments: B<< Optional[Int] >>. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Increments the counter by C<< $amount >>, or by 1 if no value is given. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
{ |
120
|
|
|
|
|
|
|
my $__signature; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub inc { |
123
|
3
|
|
|
3
|
1
|
4371
|
my $__REF__ = \$_[0]; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
package Hydrogen::Counter::__SANDBOX__; |
126
|
|
|
|
|
|
|
$__signature ||= sub { |
127
|
3
|
|
|
3
|
|
6
|
my ( %tmp, $tmp ); |
128
|
|
|
|
|
|
|
|
129
|
3
|
50
|
33
|
|
|
13
|
@_ >= 1 && @_ <= 2 |
130
|
|
|
|
|
|
|
or Hydrogen::croak( |
131
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
132
|
|
|
|
|
|
|
"inc", scalar(@_), "expected exactly 1 parameters" ); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Parameter $_[0] (type: Int) |
135
|
|
|
|
|
|
|
( |
136
|
3
|
50
|
|
|
|
4
|
do { |
137
|
3
|
|
|
|
|
6
|
my $tmp = $_[0]; |
138
|
3
|
50
|
33
|
|
|
26
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
) |
141
|
|
|
|
|
|
|
or Hydrogen::croak( |
142
|
|
|
|
|
|
|
"Type check failed in signature for inc: %s should be %s", |
143
|
|
|
|
|
|
|
"\$_[0]", "Int" ); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# Parameter $_[1] (type: Optional[Int]) |
146
|
3
|
100
|
|
|
|
12
|
$#_ >= 1 |
147
|
|
|
|
|
|
|
or return (@_); |
148
|
|
|
|
|
|
|
( |
149
|
1
|
50
|
|
|
|
9
|
do { |
150
|
1
|
|
|
|
|
13
|
my $tmp = $_[1]; |
151
|
1
|
50
|
33
|
|
|
34
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
) |
154
|
|
|
|
|
|
|
or Hydrogen::croak( |
155
|
|
|
|
|
|
|
"Type check failed in signature for inc: %s should be %s", |
156
|
|
|
|
|
|
|
"\$_[1]", "Optional[Int]" ); |
157
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
4
|
(@_); |
159
|
3
|
|
100
|
|
|
17
|
}; |
160
|
3
|
|
|
|
|
6
|
@_ = &$__signature; |
161
|
|
|
|
|
|
|
( |
162
|
3
|
|
|
|
|
5
|
${$__REF__} = do { |
|
3
|
|
|
|
|
9
|
|
163
|
3
|
100
|
|
|
|
10
|
my $shv_final_unchecked = |
164
|
|
|
|
|
|
|
$$__REF__ + ( ( @_ - 1 ) ? $_[1] : 1 ); |
165
|
3
|
|
|
|
|
4
|
do { |
166
|
|
|
|
|
|
|
( |
167
|
3
|
50
|
|
|
|
4
|
do { |
168
|
3
|
|
|
|
|
6
|
my $tmp = $shv_final_unchecked; |
169
|
3
|
50
|
33
|
|
|
24
|
defined($tmp) |
170
|
|
|
|
|
|
|
and !ref($tmp) |
171
|
|
|
|
|
|
|
and $tmp =~ /\A-?[0-9]+\z/; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
) |
174
|
|
|
|
|
|
|
or Hydrogen::croak( |
175
|
|
|
|
|
|
|
"Type check failed for inc: expected %s, got value %s", |
176
|
|
|
|
|
|
|
"Int", $shv_final_unchecked |
177
|
|
|
|
|
|
|
); |
178
|
3
|
|
|
|
|
7
|
$shv_final_unchecked; |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 C<< reset( $counter ) >> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Sets the counter to its default value, or 0 if it has no default. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub reset { |
192
|
1
|
|
|
1
|
1
|
3050
|
my $__REF__ = \$_[0]; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
package Hydrogen::Counter::__SANDBOX__; |
195
|
1
|
50
|
|
|
|
8
|
@_ == 1 |
196
|
|
|
|
|
|
|
or Hydrogen::croak( "Wrong number of parameters for reset; usage: " |
197
|
|
|
|
|
|
|
. "Hydrogen::Counter::reset( \$counter )" ); |
198
|
|
|
|
|
|
|
( |
199
|
1
|
|
|
|
|
3
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
200
|
1
|
|
|
|
|
4
|
my $shv_final_unchecked = 0; |
201
|
1
|
|
|
|
|
2
|
do { |
202
|
|
|
|
|
|
|
( |
203
|
1
|
50
|
|
|
|
2
|
do { |
204
|
1
|
|
|
|
|
2
|
my $tmp = $shv_final_unchecked; |
205
|
1
|
50
|
33
|
|
|
16
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
) |
208
|
|
|
|
|
|
|
or Hydrogen::croak( |
209
|
|
|
|
|
|
|
"Type check failed for reset: expected %s, got value %s", |
210
|
|
|
|
|
|
|
"Int", $shv_final_unchecked ); |
211
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
212
|
|
|
|
|
|
|
}; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
); |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head2 C<< set( $counter, $value ) >> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Additional arguments: B<< Int >>. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Sets the counter to the given value. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub set { |
226
|
1
|
|
|
1
|
1
|
2872
|
my $__REF__ = \$_[0]; |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
package Hydrogen::Counter::__SANDBOX__; |
229
|
1
|
|
|
|
|
3
|
@_ = do { |
230
|
1
|
|
|
|
|
3
|
my ( %tmp, $tmp ); |
231
|
|
|
|
|
|
|
|
232
|
1
|
50
|
|
|
|
5
|
@_ == 2 |
233
|
|
|
|
|
|
|
or Hydrogen::croak( |
234
|
|
|
|
|
|
|
"Wrong number of parameters in signature for %s: got %d, %s", |
235
|
|
|
|
|
|
|
"set", scalar(@_), "expected exactly 2 parameters" ); |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# Parameter $_[0] (type: Int) |
238
|
|
|
|
|
|
|
( |
239
|
1
|
50
|
|
|
|
1
|
do { |
240
|
1
|
|
|
|
|
3
|
my $tmp = $_[0]; |
241
|
1
|
50
|
33
|
|
|
15
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
) |
244
|
|
|
|
|
|
|
or Hydrogen::croak( |
245
|
|
|
|
|
|
|
"Type check failed in signature for set: %s should be %s", |
246
|
|
|
|
|
|
|
"\$_[0]", "Int" ); |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Parameter $_[1] (type: Int) |
249
|
|
|
|
|
|
|
( |
250
|
1
|
50
|
|
|
|
10
|
do { |
251
|
1
|
|
|
|
|
4
|
my $tmp = $_[1]; |
252
|
1
|
50
|
33
|
|
|
9
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
) |
255
|
|
|
|
|
|
|
or Hydrogen::croak( |
256
|
|
|
|
|
|
|
"Type check failed in signature for set: %s should be %s", |
257
|
|
|
|
|
|
|
"\$_[1]", "Int" ); |
258
|
|
|
|
|
|
|
|
259
|
1
|
|
|
|
|
5
|
(@_); |
260
|
|
|
|
|
|
|
}; |
261
|
|
|
|
|
|
|
( |
262
|
1
|
|
|
|
|
2
|
${$__REF__} = do { |
|
1
|
|
|
|
|
3
|
|
263
|
1
|
|
|
|
|
2
|
my $shv_final_unchecked = $_[1]; |
264
|
1
|
|
|
|
|
3
|
do { |
265
|
|
|
|
|
|
|
( |
266
|
1
|
50
|
|
|
|
2
|
do { |
267
|
1
|
|
|
|
|
4
|
my $tmp = $shv_final_unchecked; |
268
|
1
|
50
|
33
|
|
|
9
|
defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
) |
271
|
|
|
|
|
|
|
or Hydrogen::croak( |
272
|
|
|
|
|
|
|
"Type check failed for set: expected %s, got value %s", |
273
|
|
|
|
|
|
|
"Int", $shv_final_unchecked ); |
274
|
1
|
|
|
|
|
3
|
$shv_final_unchecked; |
275
|
|
|
|
|
|
|
}; |
276
|
|
|
|
|
|
|
} |
277
|
|
|
|
|
|
|
); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
1; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 EXPORT |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
No functions are exported by this module by default. To import them all (this is usually a bad idea), use: |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
use Hydrogen::Counter -all; |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
To import a particular function, use: |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
use Hydrogen::Counter 'reset'; |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
To rename functions: |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
use Hydrogen::Counter 'reset' => { -as => 'myfunc' }; |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
On Perl 5.37.2+ (or if L is installed) you can import lexically: |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
use Hydrogen::Counter -lexical, 'reset'; |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
See L for more hints on importing. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head1 BUGS |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
Please report any bugs to |
305
|
|
|
|
|
|
|
L. |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
=head1 SEE ALSO |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
L, |
310
|
|
|
|
|
|
|
L, |
311
|
|
|
|
|
|
|
L, |
312
|
|
|
|
|
|
|
L. |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 AUTHOR |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
Toby Inkster Etobyink@cpan.orgE. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
This software is copyright (c) 2022-2023 by Toby Inkster. |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
323
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
328
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
329
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
330
|
|
|
|
|
|
|
|