| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Algorithm::CheckDigits::M97_001; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 2 |  |  | 2 |  | 38 | use 5.006; | 
|  | 2 |  |  |  |  | 7 |  | 
| 4 | 2 |  |  | 2 |  | 10 | use strict; | 
|  | 2 |  |  |  |  | 21 |  | 
|  | 2 |  |  |  |  | 42 |  | 
| 5 | 2 |  |  | 2 |  | 9 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 46 |  | 
| 6 | 2 |  |  | 2 |  | 528 | use integer; | 
|  | 2 |  |  |  |  | 18 |  | 
|  | 2 |  |  |  |  | 9 |  | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 2 |  |  | 2 |  | 51 | use version; our $VERSION = 'v1.3.6'; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 7 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | our @ISA = qw(Algorithm::CheckDigits); | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub new { | 
| 13 | 3 |  |  | 3 | 0 | 7 | my $proto = shift; | 
| 14 | 3 |  |  |  |  | 5 | my $type  = shift; | 
| 15 | 3 |  | 33 |  |  | 16 | my $class = ref($proto) || $proto; | 
| 16 | 3 |  |  |  |  | 7 | my $self  = bless({}, $class); | 
| 17 | 3 |  |  |  |  | 18 | $self->{type} = lc($type); | 
| 18 | 3 |  |  |  |  | 15 | return $self; | 
| 19 |  |  |  |  |  |  | } # new() | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub is_valid { | 
| 22 | 5 |  |  | 5 | 1 | 27 | my ($self,$number) = @_; | 
| 23 | 5 | 50 |  |  |  | 39 | 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 | 154 | my ($self,$number) = @_; | 
| 31 | 3 | 50 |  |  |  | 18 | if ($number =~ /^(?:BE)?(\d{7,8})$/i) { | 
| 32 | 3 |  |  |  |  | 10 | 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 |  |  |  | 20 | if ($number =~ /^(?:BE)?(\d{7,8})(\d\d)$/i) { | 
| 40 | 3 | 50 |  |  |  | 7 | return $1 if ($2 eq $self->_compute_checkdigit($1)); | 
| 41 |  |  |  |  |  |  | } | 
| 42 | 0 |  |  |  |  | 0 | return ''; | 
| 43 |  |  |  |  |  |  | } # basenumber() | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub checkdigit { | 
| 46 | 3 |  |  | 3 | 1 | 7 | my ($self,$number) = @_; | 
| 47 | 3 | 50 |  |  |  | 17 | 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 |  | 26 | my $self   = shift; | 
| 55 | 14 |  |  |  |  | 32 | my $number = shift; | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 14 | 50 |  |  |  | 47 | if ($number =~ /^\d{7,8}$/i) { | 
| 58 | 14 |  |  |  |  | 129 | 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__ |