Algorithm-CheckDigits

 view release on metacpan or  search on metacpan

lib/Algorithm/CheckDigits/M07_001.pm  view on Meta::CPAN

use strict;
use warnings;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $class = ref($proto) || $proto;
	return bless({}, $class);
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9]*)([0-9])$/) {
		return ($2 == _compute_checkdigit($1));
	}
	return 0;
} # is_valid()

lib/Algorithm/CheckDigits/M09_001.pm  view on Meta::CPAN

use strict;
use warnings;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $class = ref($proto) || $proto;
	return bless({}, $class);
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([A-Za-z][0-9]{10})([0-9])$/) {
		return $2 == _compute_checkdigit($1);
	}
	return 0;
} # is_valid()

lib/Algorithm/CheckDigits/M10_001.pm  view on Meta::CPAN

my %omitprefix = (
    'jcb'      => 0,
    'enroute'  => 0,
    'discover' => 0,
);

sub new {
    my $proto = shift;
    my $type  = shift;
    my $class = ref($proto) || $proto;
    my $self  = bless( {}, $class );
    $self->{type} = lc($type);
    $self->_determine_pattern();
    return $self;
}    # new()

sub is_valid {
    my ( $self, $number ) = @_;
    if ( $number =~ /^($self->{pattern})([0-9])$/i ) {
        return $2 == $self->_compute_checkdigit( uc($1) );
    }

lib/Algorithm/CheckDigits/M10_002.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9 ]*)([0-9])$/) {
		return $2 == $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M10_003.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^M([0-9-]*)([0-9])$/i) {
		return ($2 == $self->_compute_checkdigit($1));
	}
	return ''

lib/Algorithm/CheckDigits/M10_004.pm  view on Meta::CPAN

        978 => 1,
        979 => 1,
    },
    issn13 => { 977 => 1, },
};

sub new {
    my $proto = shift;
    my $type  = shift;
    my $class = ref($proto) || $proto;
    my $self  = bless( {}, $class );
    $self->{type} = lc($type);
    return $self;
}    # new()

sub is_valid {
    my ( $self, $number ) = @_;
    if ( $number =~ /^([0-9 -]+)([0-9])$/ ) {
        return $2 == $self->_compute_checkdigit($1);
    }
    return '';

lib/Algorithm/CheckDigits/M10_005.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9 .]{11,})([0-9])$/) {
		return $2 == $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M10_006.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 2,1,2,5,7,1,2,1,2,1,2,1 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{8}[A-Za-z]\d\d)(\d)$/) {
		return $2 == $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M10_008.pm  view on Meta::CPAN

my %ctable = map { $_, $value++ } ( '0'..'9', 'A'..'Z' );

my $re_alpha = qr/[B-DF-HJ-NP-TV-Z]/;
my $re_alnum = qr/[0-9B-DF-HJ-NP-TV-Z]/;
my $re_sedol = qr/(\d{6}|$re_alpha$re_alnum{5})(\d)?/;

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my $self = shift;
	my $number = uc shift;

	if ($number =~ /^$re_sedol$/o) {
		return $2 == $self->_compute_checkdigit($1);

lib/Algorithm/CheckDigits/M10_009.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9 ]*)([0-9])$/) {
		my $cd = $self->_compute_checkdigit($1);
		return ($2 == $cd || $2 == ((5 + $cd) % 10));
	}

lib/Algorithm/CheckDigits/M10_010.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @items = ( 0,9,4,6,8,2,7,1,3,5 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d\d-?\d{8})-?(\d)$/) {
		return $2 == $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M10_011.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(.*)([0-9])$/) {
		return $2 == $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_001.pm  view on Meta::CPAN

	'vat_sl'	=> [ 1, 0, 2, 3, 4, 5, 6, 7, 8, 9,  0, -1 ], # ?
};

$cd->{'issn'} = $cd->{'isbn'};
$cd->{'vatrn_pt'} = $cd->{'ustid_pt'};

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(.+)(.)$/) {
		return uc($2) eq $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_002.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(.+)(.)$/) {
		return uc($2) eq $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_003.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 4,2,1,6,3,7,9,10,5,8,4,2 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{11})(\d)$/) {
		return $2 == $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_004.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([-\d.]+)(\d\d)$/) {
		return $2 eq $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_006.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 6, 3, 7, 9, 10, 5, 8, 4, 2, 1 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{4}-?\d{4})-?(\d\d)-?(\d{10})$/) {
		return uc($2) eq $self->_compute_checkdigits($1,$3);
	}
	return ''

lib/Algorithm/CheckDigits/M11_007.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 7, 9, 10, 5, 8, 4, 2 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{7})(\d)$/) {
		return uc($2) eq $self->_compute_checkdigits($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_008.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 2, 7, 6, 5, 4, 3, 2, 1 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{8})$/) {
		return 0 == $self->_compute_checkdigits($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_009.pm  view on Meta::CPAN

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 2, 7, 6, 5, 4, 3, 2 );

my @keys   = ('', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'Z', 'J' );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([fgst])?(\d{7})([a-jz])$/i) {
		return (uc($3) eq $self->_compute_checkdigits($2));
	}
	return ''

lib/Algorithm/CheckDigits/M11_010.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 5, 4, 3, 2, 7, 6, 5, 4, 3, 2 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9.]+)(\d)$/) {
		return $2 == $self->_compute_checkdigits($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_011.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9]+)(\d)(B\d\d)?$/i) {
		return $2 == $self->_compute_checkdigits($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_012.pm  view on Meta::CPAN

	C => 16, D => 18, E => 20, F => 22, G => 24, H => 26,
	I => 28, J => 6, K => 8, L => 10, M => 12, N => 14,
	O => 16, P => 18, Q => 20, R => 22, S => 4, T => 6,
	U => 8, V => 10, W => 12, X => 14, Y => 16, Z => 18,
);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([-0-9a-z]+)(\d)$/i) {
		return $2 == $self->_compute_checkdigits($1);
	}
	return undef;

lib/Algorithm/CheckDigits/M11_013.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9]+)(\d)$/) {
		return $2 == $self->_compute_checkdigits($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_015.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 2, 3, 4, 5, 6, 7 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d\d)([\d ]+)$/) {
		return $1 == $self->_compute_checkdigits($2);
	}
	return ''

lib/Algorithm/CheckDigits/M11_016.pm  view on Meta::CPAN

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

my @weight = ( 6, 5, 7, 2, 3, 4, 5, 6, 7 );

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{9})(\d)$/) {
		return $2 == $self->_compute_checkdigits($1);
	}
	return ''

lib/Algorithm/CheckDigits/M11_017.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
    my $proto = shift;
    my $type  = shift;
    my $class = ref($proto) || $proto;
    my $self  = bless( {}, $class );
    $self->{type} = lc($type);
    return $self;
}    # new()

sub is_valid {
    my ( $self, $number ) = @_;
    if ( $number =~ /^([-\d]+)(\d)$/ ) {
        return $2 eq $self->_compute_checkdigit($1);
    }
    return '';

lib/Algorithm/CheckDigits/M16_001.pm  view on Meta::CPAN

use integer;

use version; our $VERSION = 'v1.3.6';

our @ISA = qw(Algorithm::CheckDigits);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^([0-9a-f]{15})([0-9a-f])$/i) {
		return $2 eq $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M23_001.pm  view on Meta::CPAN

my @keytable = (
	'T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F',
	'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S',
	'Q', 'V', 'H', 'L', 'C', 'K', 'E',
);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{8})-?([A-HJ-NP-TV-Z])$/i) {
		return $2 eq $self->_compute_checkdigit($1);
	}
	return ''

lib/Algorithm/CheckDigits/M23_002.pm  view on Meta::CPAN

my @keytable = (
	'W', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
	'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
	'P', 'Q', 'R', 'S', 'T', 'U', 'V', 
);

sub new {
	my $proto = shift;
	my $type  = shift;
	my $class = ref($proto) || $proto;
	my $self  = bless({}, $class);
	$self->{type} = lc($type);
	return $self;
} # new()

sub is_valid {
	my ($self,$number) = @_;
	if ($number =~ /^(\d{7})([A-W])([A-IW])?$/i) {
		return $2 eq $self->_compute_checkdigit($1,$3);
	}
	return ''



( run in 1.231 second using v1.01-cache-2.11-cpan-de7293f3b23 )