line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CBOR::Free::AddOne; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
764
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
291
|
|
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
|
57809
|
my @digits = unpack '(a)*', shift(); |
11
|
|
|
|
|
|
|
|
12
|
103
|
|
|
|
|
188
|
my $done; |
13
|
|
|
|
|
|
|
|
14
|
103
|
|
|
|
|
150
|
my $carry = 1; |
15
|
|
|
|
|
|
|
|
16
|
103
|
|
|
|
|
232
|
for my $d ( reverse( 0 .. $#digits ) ) { |
17
|
108
|
|
|
|
|
210
|
$digits[$d] += $carry; |
18
|
108
|
|
|
|
|
159
|
$carry = 0; |
19
|
|
|
|
|
|
|
|
20
|
108
|
100
|
|
|
|
238
|
if ($digits[$d] > 9) { |
21
|
5
|
|
|
|
|
9
|
$carry = $digits[$d] - 9; |
22
|
5
|
|
|
|
|
9
|
$digits[$d] = 0; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
108
|
100
|
|
|
|
229
|
last if !$carry; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
103
|
|
33
|
|
|
812
|
return join( q<>, $carry || (), @digits ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |