1Algorithm::CheckDigits:U:sMe1r1_C0o1n3t(r3i)buted Perl DAolcguomreintthamt:i:oCnheckDigits::M11_013(3)
2
3
4
6 CheckDigits::M11_013 - compute check digits for VAT Registration Number
7 (GR)
8
10 use Algorithm::CheckDigits;
11
12 $ustid = CheckDigits('ustid_gr');
13
14 if ($ustid->is_valid('123456783')) {
15 # do something
16 }
17
18 $cn = $ustid->complete('12345678');
19 # $cn = '123456783'
20
21 $cd = $ustid->checkdigit('123456783');
22 # $cd = '3'
23
24 $bn = $ustid->basenumber('123456783');
25 # $bn = '12345678';
26
28 ALGORITHM
29 1. Beginning right with the digit before the checkdigit all digits are
30 weighted with 2 ** position. I. e. the last digit is multiplied
31 with 2, the next with 4, then 8 and so on.
32
33 2. The weighted digits are added.
34
35 3. The sum from step 2 is taken modulo 11.
36
37 4. If the sum from step 3 is greater than 9, the check sum is 0 else
38 it is the sum itself.
39
40 METHODS
41 is_valid($number)
42 Returns true only if $number consists solely of numbers and the
43 rightmost digit is a valid check digit according to the algorithm
44 given above.
45
46 Returns false otherwise,
47
48 complete($number)
49 The check digit for $number is computed and appended to the end of
50 $number.
51
52 Returns the complete number with check digit or '' if $number does
53 not consist solely of digits.
54
55 basenumber($number)
56 Returns the basenumber of $number if $number has a valid check
57 digit.
58
59 Return '' otherwise.
60
61 checkdigit($number)
62 Returns the check digits of $number if $number has valid check
63 digits.
64
65 Return '' otherwise.
66
67 EXPORT
68 None by default.
69
71 Mathias Weidner, "<mamawe@cpan.org>"
72
74 perl, CheckDigits, www.pruefziffernberechnung.de,
75
76
77
78perl v5.32.1 2021-01-26Algorithm::CheckDigits::M11_013(3)