Algorithm::CheckDigits - Perl extension to generate and test check digits


NAME

Algorithm::CheckDigits - Perl extension to generate and test check digits


SYNOPSIS

  perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods

or

  use Algorithm::CheckDigits;

  @ml = Algorithm::CheckDigits->method_list();
  $isbn = CheckDigits('ISBN');
  if ($isbn->is_valid('3-930673-48-7')) {
        # do something
  }
  $cn = $isbn->complete('3-930673-48');     # $cn = '3-930673-48-7'
  $cd = $isbn->checkdigit('3-930673-48-7'); # $cd = '7'
  $bn = $isbn->basenumber('3-930673-48-7'); # $bn = '3-930673-48'


ABSTRACT

This module provides a number of methods to test and generate check digits. For more information have a look at the web site www.pruefziffernberechnung.de (german).


SUBROUTINES/METHODS

CheckDigits($method)

Returns an object of an appropriate Algorithm::CheckDigits class for the given algorithm.

Dies with an error message if called with an unknown algorithm.

See below for the available algorithms. Every object understands the following methods:

is_valid($number)
Returns true or false if $number contains/contains no valid check digit.

complete($number)
Returns a string representation of $number completed with the appropriate check digit.

checkdigit($number)
Extracts the check digit from $number if $number contains a valid check digit.

basenumber($number)
Extracts the basenumber from $number if $number contains a valid check digit.

Algorithm::CheckDigits::method_list()

Returns a list of known methods for check digit computation.

Algorithm::CheckDigits::print_methods()

Returns a list of known methods for check digit computation.

You may use the following to find out which methods your version of Algorithm::CheckDigits provides and where to look for further information.

 perl -MAlgorithm::CheckDigits -e Algorithm::CheckDigits::print_methods

CHECK SUM METHODS

At the moment these methods to compute check digits are provided: (vatrn - VAT Return Number, in german ustid UmsatzSTeuer-ID)

m07-001
See the Algorithm::CheckDigits::M07_001 manpage.

euronote, m09-001
European bank notes, see the Algorithm::CheckDigits::M09_001 manpage.

amex, bahncard, diners, discover, enroute, eurocard, happydigits, isin, jcb, klubkarstadt, mastercard, miles&more, visa, m09-001, imei, imeisv
See the Algorithm::CheckDigits::M10_001 manpage.

siren, siret, m10-002
See the Algorithm::CheckDigits::M10_002 manpage.

ismn, m10-003
See the Algorithm::CheckDigits::M10_003 manpage.

ean, iln, isbn13, nve, 2aus5, m10-004
See the Algorithm::CheckDigits::M10_004 manpage.

identcode_dp, leitcode_dp, m10-005
See the Algorithm::CheckDigits::M10_005 manpage.

rentenversicherung, m10-006
See the Algorithm::CheckDigits::M10_006 manpage.

sedol, m10-008
See the Algorithm::CheckDigits::M10_008 manpage.

betriebsnummer, m10-009
See the Algorithm::CheckDigits::M10_009 manpage.

postscheckkonti, m10-010
See the Algorithm::CheckDigits::M10_010 manpage.

ups, m10-011
See the Algorithm::CheckDigits::M10_011 manpage.

hkid, isbn, issn, nhs_gb, ustid_pt, vat_sl, wagonnr_br, m11-001
See the Algorithm::CheckDigits::M11_001 manpage.

pzn, m11-002
See the Algorithm::CheckDigits::M11_002 manpage.

pkz, m11-003
See the Algorithm::CheckDigits::M11_003 manpage.

cpf, titulo_eleitor, m11-004
See the Algorithm::CheckDigits::M11_004 manpage.

ccc_es, m11-006
See the Algorithm::CheckDigits::M11_006 manpage.

ustid_fi, vatrn_fi, m11-007
See the Algorithm::CheckDigits::M11_007 manpage.

ustid_dk, vatrn_dk, m11-008
See the Algorithm::CheckDigits::M11_008 manpage.

nric_sg, m11-009
See the Algorithm::CheckDigits::M11_009 manpage.

ahv_ch, m11-010
See the Algorithm::CheckDigits::M11_010 manpage.

ustid_nl, vatrn_nl, m11-011
See the Algorithm::CheckDigits::M11_011 manpage.

bwpk_de, m11-012
See the Algorithm::CheckDigits::M11_012 manpage.

ustid_gr, vatrn_gr, m11-013
See the Algorithm::CheckDigits::M11_013 manpage.

esr5_ch, m11-015
See the Algorithm::CheckDigits::M11_015 manpage.

ustid_pl, vatrn_pl, m11-016
See the Algorithm::CheckDigits::M11_016 manpage.

ecno, ec-no, einecs, elincs, m11-017
See the Algorithm::CheckDigits::M11_017 manpage.

isan, m16-001
See the Algorithm::CheckDigits::M16_001 manpage.

dni_es, m23-001
See the Algorithm::CheckDigits::M23_001 manpage.

ustid_ie, vatrn_ie, m23-002
See the Algorithm::CheckDigits::M23_002 manpage.

code_39, m43-001
See the Algorithm::CheckDigits::M43_001 manpage.

ustid_lu, vatrn_lu, m89-001
See the Algorithm::CheckDigits::M89_001 manpage.

ustid_be, vatrn_be, m97-001
See the Algorithm::CheckDigits::M97_001 manpage.

iban, m97-002
See the Algorithm::CheckDigits::M97_002 manpage.

upc, mbase-001
See the Algorithm::CheckDigits::MBase_001 manpage.

blutbeutel, bzue_de, ustid_de, vatrn_de, mbase-002
See the Algorithm::CheckDigits::MBase_002 manpage.

sici, mbase-003
See the Algorithm::CheckDigits::MBase_003 manpage.

pa_de, mxx-001
See the Algorithm::CheckDigits::MXX_001 manpage.

cas, mxx-002
See the Algorithm::CheckDigits::MXX_002 manpage.

dem, mxx-003
Old german bank notes (DEM), see the Algorithm::CheckDigits::MXX_003 manpage.

ustid_at, vatrn_at, mxx-004
See the Algorithm::CheckDigits::MXX_004 manpage.

esr9_ch, mxx-005
See the Algorithm::CheckDigits::MXX_005 manpage.

verhoeff, mxx-006
Verhoeff scheme, see the Algorithm::CheckDigits::MXX_006 manpage or the Algorithm::Verhoeff manpage

EXPORT

None by default.


SEE ALSO

the perl manpage, www.pruefziffernberechnung.de.


AUTHOR

Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>


THANKS

Petri Oksanen made me aware that CheckDigits('IMEI') would invoke no test at all since there was no entry for this in the methods hash.


COPYRIGHT AND LICENSE

Copyright 2004-2006 by Mathias Weidner

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 Algorithm::CheckDigits - Perl extension to generate and test check digits