line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CBOR::Free::AddOne; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
568
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
47
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
232
|
|
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
|
52702
|
my @digits = unpack '(a)*', shift(); |
11
|
|
|
|
|
|
|
|
12
|
103
|
|
|
|
|
142
|
my $done; |
13
|
|
|
|
|
|
|
|
14
|
103
|
|
|
|
|
127
|
my $carry = 1; |
15
|
|
|
|
|
|
|
|
16
|
103
|
|
|
|
|
187
|
for my $d ( reverse( 0 .. $#digits ) ) { |
17
|
112
|
|
|
|
|
179
|
$digits[$d] += $carry; |
18
|
112
|
|
|
|
|
114
|
$carry = 0; |
19
|
|
|
|
|
|
|
|
20
|
112
|
100
|
|
|
|
219
|
if ($digits[$d] > 9) { |
21
|
13
|
|
|
|
|
17
|
$carry = $digits[$d] - 9; |
22
|
13
|
|
|
|
|
17
|
$digits[$d] = 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
112
|
100
|
|
|
|
198
|
last if !$carry; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
103
|
|
66
|
|
|
641
|
return join( q<>, $carry || (), @digits ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |