1CheckDigits::MXX_001(3)User Contributed Perl DocumentatioCnheckDigits::MXX_001(3)
2
3
4
6 CheckDigits::MXX_001 - compute check digits for PA (DE)
7
9 use Algorithm::CheckDigits;
10
11 $pa = CheckDigits('pa_de');
12
13 if ($pa->is_valid('2406055684D<<6810203<0705109<6')) {
14 # do something
15 }
16
17 $cn = $pa->complete('240605568_D<<681020_<070510_<_');
18 # $cn = '2406055684D<<6810203<0705109<6'
19
20 $cd = $pa->checkdigit('2406055684D<<6810203<0705109<6');
21 # $cd = '6'
22
23 $bn = $pa->basenumber('2406055684D<<6810203<0705109<6');
24 # $bn = '240605568_D<<681020_<070510_<_'
25
27 ALGORITHM
28 1. Beginning left all digits are weighted with 7,3,1,7,3,1,...
29
30 2. The sum of those products is computed.
31
32 3. The checksum is the last digit of the sum from step 2 (modulo 10).
33
34 4. Step 1 to 3 is performed for every part of the number and for all 3
35 parts including the particular checkdigit to compute the total
36 checksum.
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, <mathias@weidner.in-bad-schmiedeberg.de>
70
72 Aaron W. West pointed me to a fault in the computing of the check
73 digit.
74
76 perl, CheckDigits, www.pruefziffernberechnung.de,
77 www.export911.com/e911/coding/upcChar.htm,
78 www.adams1.com/pub/russadam/upccode.html, http://www.upcdatabase.com.
79
80
81
82perl v5.12.1 2009-11-20 CheckDigits::MXX_001(3)