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

NAME

6       CheckDigits::MXX_002 - compute check digits for CAS
7

SYNOPSIS

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

DESCRIPTION

27   ALGORITHM
28       1.  Beginning right with the second digit all digits are weighted
29           ascending starting with 1.
30
31       2.  The sum of those products is computed.
32
33       3.  The checksum is the last digit of the sum from step 2 (modulo 10).
34
35   METHODS
36       is_valid($number)
37           Returns true only if $number consists solely of numbers and the
38           last digit is a valid check digit according to the algorithm given
39           above.
40
41           Returns false otherwise,
42
43       complete($number)
44           The check digit for $number is computed and concatenated to the end
45           of $number.
46
47           Returns the complete number with check digit or '' if $number does
48           not consist solely of digits and spaces.
49
50       basenumber($number)
51           Returns the basenumber of $number if $number has a valid check
52           digit.
53
54           Return '' otherwise.
55
56       checkdigit($number)
57           Returns the checkdigit of $number if $number has a valid check
58           digit.
59
60           Return '' otherwise.
61
62   EXPORT
63       None by default.
64

AUTHOR

66       Mathias Weidner, "<mamawe@cpan.org>"
67

THANKS

69       Aaron W. West pointed me to a fault in the computing of the check
70       digit.
71
72       HERMIER Christophe made me aware that CAS is now assigning 10-digit CAS
73       Registry Numbers (http://www.cas.org/newsevents/10digitrn.html)
74

SEE ALSO

76       perl, CheckDigits, www.pruefziffernberechnung.de, www.cas.org
77       http://www.cas.org/expertise/cascontent/registry/checkdig.html
78
79
80
81perl v5.32.0                      2020-07-28Algorithm::CheckDigits::MXX_002(3)
Impressum