| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Algorithm::CheckDigits::M97_001; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
37
|
use 5.006; |
|
|
2
|
|
|
|
|
8
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
43
|
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
54
|
|
|
6
|
2
|
|
|
2
|
|
497
|
use integer; |
|
|
2
|
|
|
|
|
16
|
|
|
|
2
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
52
|
use version; our $VERSION = 'v1.3.5'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
10
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Algorithm::CheckDigits); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
3
|
|
|
3
|
0
|
6
|
my $proto = shift; |
|
14
|
3
|
|
|
|
|
6
|
my $type = shift; |
|
15
|
3
|
|
33
|
|
|
18
|
my $class = ref($proto) || $proto; |
|
16
|
3
|
|
|
|
|
8
|
my $self = bless({}, $class); |
|
17
|
3
|
|
|
|
|
18
|
$self->{type} = lc($type); |
|
18
|
3
|
|
|
|
|
16
|
return $self; |
|
19
|
|
|
|
|
|
|
} # new() |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub is_valid { |
|
22
|
5
|
|
|
5
|
1
|
21
|
my ($self,$number) = @_; |
|
23
|
5
|
50
|
|
|
|
36
|
if ($number =~ /^(?:BE)?(\d{7,8})?(\d\d)$/i) { |
|
24
|
5
|
|
|
|
|
13
|
return $2 eq $self->_compute_checkdigit($1); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
0
|
|
|
|
|
0
|
return '' |
|
27
|
|
|
|
|
|
|
} # is_valid() |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub complete { |
|
30
|
3
|
|
|
3
|
1
|
158
|
my ($self,$number) = @_; |
|
31
|
3
|
50
|
|
|
|
20
|
if ($number =~ /^(?:BE)?(\d{7,8})$/i) { |
|
32
|
3
|
|
|
|
|
9
|
return $number . $self->_compute_checkdigit($1); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
0
|
|
|
|
|
0
|
return ''; |
|
35
|
|
|
|
|
|
|
} # complete() |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub basenumber { |
|
38
|
3
|
|
|
3
|
1
|
8
|
my ($self,$number) = @_; |
|
39
|
3
|
50
|
|
|
|
19
|
if ($number =~ /^(?:BE)?(\d{7,8})(\d\d)$/i) { |
|
40
|
3
|
50
|
|
|
|
9
|
return $1 if ($2 eq $self->_compute_checkdigit($1)); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
0
|
|
|
|
|
0
|
return ''; |
|
43
|
|
|
|
|
|
|
} # basenumber() |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub checkdigit { |
|
46
|
3
|
|
|
3
|
1
|
8
|
my ($self,$number) = @_; |
|
47
|
3
|
50
|
|
|
|
18
|
if ($number =~ /^(?:BE)?(\d{7,8})(\d\d)$/i) { |
|
48
|
3
|
50
|
|
|
|
11
|
return $2 if (uc($2) eq $self->_compute_checkdigit($1)); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
0
|
return ''; |
|
51
|
|
|
|
|
|
|
} # checkdigit() |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _compute_checkdigit { |
|
54
|
14
|
|
|
14
|
|
29
|
my $self = shift; |
|
55
|
14
|
|
|
|
|
33
|
my $number = shift; |
|
56
|
|
|
|
|
|
|
|
|
57
|
14
|
50
|
|
|
|
49
|
if ($number =~ /^\d{7,8}$/i) { |
|
58
|
14
|
|
|
|
|
132
|
return sprintf("%2.2d",97 - ($number % 97)); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
|
return -1; |
|
61
|
|
|
|
|
|
|
} # _compute_checkdigit() |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
__END__ |