line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CBOR::Free::AddOne; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
733
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
266
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# Hard to believe there’s not some simple module out there |
7
|
|
|
|
|
|
|
# that already does this. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub to_nonnegative_integer { |
10
|
103
|
|
|
103
|
0
|
56585
|
my @digits = unpack '(a)*', shift(); |
11
|
|
|
|
|
|
|
|
12
|
103
|
|
|
|
|
173
|
my $done; |
13
|
|
|
|
|
|
|
|
14
|
103
|
|
|
|
|
143
|
my $carry = 1; |
15
|
|
|
|
|
|
|
|
16
|
103
|
|
|
|
|
238
|
for my $d ( reverse( 0 .. $#digits ) ) { |
17
|
112
|
|
|
|
|
219
|
$digits[$d] += $carry; |
18
|
112
|
|
|
|
|
149
|
$carry = 0; |
19
|
|
|
|
|
|
|
|
20
|
112
|
100
|
|
|
|
259
|
if ($digits[$d] > 9) { |
21
|
10
|
|
|
|
|
15
|
$carry = $digits[$d] - 9; |
22
|
10
|
|
|
|
|
18
|
$digits[$d] = 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
112
|
100
|
|
|
|
240
|
last if !$carry; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
103
|
|
66
|
|
|
740
|
return join( q<>, $carry || (), @digits ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |