line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Business::BR::Ids::Common;
|
3
|
|
|
|
|
|
|
|
4
|
17
|
|
|
17
|
|
35002
|
use 5;
|
|
17
|
|
|
|
|
43
|
|
5
|
17
|
|
|
17
|
|
71
|
use strict;
|
|
17
|
|
|
|
|
20
|
|
|
17
|
|
|
|
|
321
|
|
6
|
17
|
|
|
17
|
|
59
|
use warnings;
|
|
17
|
|
|
|
|
27
|
|
|
17
|
|
|
|
|
4770
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter;
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw( _dot _dot_10 _canon_i _canon_id );
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.00_18';
|
14
|
|
|
|
|
|
|
$VERSION = eval $VERSION;
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _dot {
|
17
|
8120
|
|
|
8120
|
|
7197
|
my $a = shift;
|
18
|
8120
|
|
|
|
|
5614
|
my $b = shift;
|
19
|
8120
|
100
|
|
|
|
12894
|
warn "arguments a and b should have the same length"
|
20
|
|
|
|
|
|
|
unless (@$a==@$b);
|
21
|
8120
|
|
|
|
|
6047
|
my $s = 0;
|
22
|
8120
|
|
|
|
|
12527
|
for ( my $i=0; $i<@$a; $i++ ) {
|
23
|
84490
|
|
|
|
|
73186
|
my ($x, $y) = ($a->[$i], $b->[$i]);
|
24
|
84490
|
100
|
100
|
|
|
217475
|
if ($x && $y) {
|
25
|
69518
|
|
|
|
|
110081
|
$s += $x*$y;
|
26
|
|
|
|
|
|
|
}
|
27
|
|
|
|
|
|
|
}
|
28
|
8120
|
|
|
|
|
16388
|
return $s;
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _dot_10 {
|
32
|
403
|
|
|
403
|
|
934
|
my $a = shift;
|
33
|
403
|
|
|
|
|
242
|
my $b = shift;
|
34
|
403
|
50
|
|
|
|
542
|
warn "arguments a and b should have the same length"
|
35
|
|
|
|
|
|
|
unless (@$a==@$b);
|
36
|
403
|
|
|
|
|
267
|
my $s = 0;
|
37
|
403
|
|
|
|
|
589
|
for ( my $i=0; $i<@$a; $i++ ) {
|
38
|
4821
|
|
|
|
|
3822
|
my ($x, $y) = ($a->[$i], $b->[$i]);
|
39
|
4821
|
100
|
100
|
|
|
11065
|
if ( $x && $y ) {
|
40
|
3978
|
|
|
|
|
3008
|
my $xy = $x*$y;
|
41
|
3978
|
|
|
|
|
8781
|
$s += $_ for split('', $xy); # sum each digit of the product
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
}
|
44
|
403
|
|
|
|
|
706
|
return $s;
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
17
|
|
|
17
|
|
85
|
use Scalar::Util qw(looks_like_number);
|
|
17
|
|
|
|
|
31
|
|
|
17
|
|
|
|
|
5064
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# usage: _canon_i($piece, size => 12)
|
50
|
|
|
|
|
|
|
sub _canon_i {
|
51
|
0
|
|
|
0
|
|
0
|
my $piece = shift;
|
52
|
0
|
|
|
|
|
0
|
my %options = @_;
|
53
|
0
|
0
|
0
|
|
|
0
|
if (looks_like_number($piece) && int($piece)==$piece) {
|
54
|
0
|
|
|
|
|
0
|
return sprintf('%0*s', $options{size}, $piece)
|
55
|
|
|
|
|
|
|
} else {
|
56
|
0
|
|
|
|
|
0
|
$piece =~ s/\D//g;
|
57
|
0
|
|
|
|
|
0
|
return $piece;
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _canon_id {
|
62
|
2927
|
|
|
2927
|
|
2891
|
my $piece = shift;
|
63
|
2927
|
|
|
|
|
5377
|
my %options = @_;
|
64
|
2927
|
100
|
66
|
|
|
14199
|
if (looks_like_number($piece) && int($piece)==$piece) {
|
65
|
2838
|
|
|
|
|
11853
|
return sprintf('%0*s', $options{size}, $piece)
|
66
|
|
|
|
|
|
|
} else {
|
67
|
89
|
|
|
|
|
449
|
$piece =~ s/[\W_]//g;
|
68
|
89
|
|
|
|
|
272
|
return $piece;
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1;
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__
|