1Algorithm::CheckDigits:U:sMe1r0_C0o1n0t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M10_010(3)
2
3
4
6 CheckDigits::M10_010 - compute check digits for Postscheckkonti (CH)
7
9 use Algorithm::CheckDigits;
10
11 $pck = CheckDigits('postcheckkonti');
12
13 if ($pck->is_valid('85-12345678-7')) {
14 # do something
15 }
16
17 $cn = $pck->complete('85-12345678');
18 # $cn = '85-12345678-7'
19
20 $cd = $pck->checkdigit('85-12345678-7');
21 # $cd = '7'
22
23 $bn = $pck->basenumber('85-12345678-7');
24 # $bn = '85-12345678'
25
27 ALGORITHM
28 1. The sequence of digits is processed left to right. For the first
29 digit we assume a carry forward of 0.
30
31 2. For each digit d(i) the carry forward cf(i) is the digit at the the
32 position p in the sequence ( 0, 9, 4, 6, 8, 2, 7, 1, 3, 5 ), where
33 p is (d(i) + cf(i-1)) modulo 10.
34
35 3. The check digit is the difference of the sum from step 3 to the
36 next multiple of 10.
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 and spaces.
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.34.0 2021-07-22Algorithm::CheckDigits::M10_010(3)