1Algorithm::CheckDigits:U:sMe1r1_C0o0n1t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M11_001(3)
2
3
4

NAME

6       CheckDigits::M11_001 - compute check digits for ISBN, ISSN, VAT RN
7       (PT), HKID (HK), Wagon number (BR), NHS (GB), VAT (SL)
8

SYNOPSIS

10         use Algorithm::CheckDigits;
11
12         $isbn = CheckDigits('isbn');
13
14         if ($isbn->is_valid('3-88229-192-3')) {
15               # do something
16         }
17
18         $cn = $isbn->complete('3-88229-192-');
19         # $cn = '3-88229-192-3'
20
21         $cd = $isbn->checkdigit('3-88229-192-3');
22         # $cd = '3'
23
24         $bn = $isbn->basenumber('3-88229-192-3');
25         # $bn = '3-88229-192-'
26

DESCRIPTION

28   ALGORITHM
29       1.  The sequence of digits is processed right to left.  Every digit is
30           multiplied with their position in the sequence (i.e.  the digit
31           left to the check digit has the weight 2 then 3 etc.).
32
33           With a Hongkong ID (hkid) the leftmost char is replaced with its
34           position in the alphabet and then multiplied with 8 (its weight).
35
36       2.  The sum of all products is computed.
37
38       3.  The sum of step 2 is taken modulo 11.
39
40       4.  The checkdigit is the difference of the sum from step 3 to eleven
41           under the following conditions:
42
43           isbn,issn
44                   If the difference is 10, the check digit is 'X'.
45
46                   If the difference is 11, the check digit is 0.
47
48           ustid_pt
49                   If the difference is greater then 9, the check digit is
50                   '0'.
51
52           hkid    If the difference is 10, the check digit is 'A'.
53
54                   If the difference is 11, the check digit is 0.
55
56           wagonnr_br
57                   If the difference is 10, the check digit is 0.
58
59                   If the difference is 11, the check digit is 1.
60
61           nhs_gb  If the difference is 10, the number would not be taken.
62
63                   If the difference is 11, the check digit is 0.
64
65           vat_sl  This is a little bit unclear, don't trust on the method for
66                   this type.
67
68   METHODS
69       is_valid($number)
70           Returns true only if $number consists solely of numbers and the
71           last digit is a valid check digit according to the algorithm given
72           above.
73
74           Returns false otherwise,
75
76       complete($number)
77           The check digit for $number is computed and concatenated to the end
78           of $number.
79
80           Returns the complete number with check digit or '' if $number does
81           not consist solely of digits and spaces.
82
83       basenumber($number)
84           Returns the basenumber of $number if $number has a valid check
85           digit.
86
87           Return '' otherwise.
88
89       checkdigit($number)
90           Returns the checkdigit of $number if $number has a valid check
91           digit.
92
93           Return '' otherwise.
94
95   EXPORT
96       None by default.
97

AUTHOR

99       Mathias Weidner, "<mamawe@cpan.org>"
100

SEE ALSO

102       perl, CheckDigits, www.pruefziffernberechnung.de.
103
104
105
106perl v5.36.0                      2022-07-22Algorithm::CheckDigits::M11_001(3)
Impressum