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