1Algorithm::CheckDigits:U:sMe0r9_C0o0n1t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M09_001(3)
2
3
4
6 CheckDigits::M09_001 - compute check digits for Euro notes
7
9 use Algorithm::CheckDigits;
10
11 $euro = CheckDigits('euronote');
12
13 if ($euro->is_valid('X07738250357')) {
14 # do something
15 }
16
17 $cn = $euro->complete('X0773825035'); # $cn = 'X07738250357'
18
19 $cd = $euro->checkdigit('X07738250357'); # $cd = '7'
20
21 $bn = $euro->basenumber('X07738250357'); # $bn = 'X0773825035'
22
24 ALGORITHM
25 1. Letters are replaced with their position in the alphabet ('A' = 1,
26 ...).
27
28 2. The total of the digits of all numbers is computed.
29
30 3. This sum is taken modulo 9.
31
32 4. The check digit is the difference between 8 and the number of step
33 3.
34
35 To validate the last digit of the total of the digits of all numbers
36 inclusive check digit must be 8.
37
38 METHODS
39 is_valid($number)
40 Returns true only if $number consists solely of numbers and the
41 last digit is a valid check digit according to the algorithm given
42 above.
43
44 Returns false otherwise,
45
46 complete($number)
47 The check digit for $number is computed and concatenated to the end
48 of $number.
49
50 Returns the complete number with check digit or '' if $number does
51 not consist solely of digits.
52
53 basenumber($number)
54 Returns the basenumber of $number if $number has a valid check
55 digit.
56
57 Return '' otherwise.
58
59 checkdigit($number)
60 Returns the checkdigit of $number if $number has a valid check
61 digit.
62
63 Return '' otherwise.
64
65 EXPORT
66 None by default.
67
69 Mathias Weidner, "<mamawe@cpan.org>"
70
72 perl, CheckDigits, www.pruefziffernberechnung.de.
73
74
75
76perl v5.30.0 2019-07-26Algorithm::CheckDigits::M09_001(3)