Compute check digits for sici (serial item and contribution identifier)
use Algorithm::CheckDigits; $sici = CheckDigits('sici'); if ($sici->is_valid('0784-8679(20040308)6:<138>2.0.TX;2-H')) { # do something } $cn = $sici->complete('0784-8679(20040308)6:<138>2.0.TX;2-'); # $cn = '0784-8679(20040308)6:<138>2.0.TX;2-H' $cd = $sici->checkdigit('0784-8679(20040308)6:<138>2.0.TX;2-H'); # $cd = 'H' $bn = $sici->basenumber('0784-8679(20040308)6:<138>2.0.TX;2-H'); # $bn = '0784-8679(20040308)6:<138>2.0.TX;2-';
In the string describing the number all letters (A-Z) are replaced with numbers 10-35 accordingly. All other non-numbers are replaced by 36.
Beginning right the numbers at all odd positions are added.
The sum from step 1 is multiplied by 3.
Beginning right the numbers at all even positions are added.
The sums from step 2 and 3 are added.
The sum from step 4 is taken modulo 37.
The checksum is 37 minus the sum from step 5 where numbers from 10 to 35 are represented by 'A' to 'Z' accordingly and 36 is represented by '#'.
Returns true only if $number consists solely of numbers and hyphens and the two digits in the middle are valid check digits according to the algorithm given above. Returns false otherwise,
The check digit for $number is computed and inserted into the middle of $number. Returns the complete number with check digit or '' if $number does not consist solely of digits, hyphens and spaces.
Returns the basenumber of $number if $number has a valid check digit. Return '' otherwise.
Returns the check digits of $number if $number has valid check digits. Return '' otherwise.
None by default.
Mathias Weidner, <[email protected]>
perl, CheckDigits, www.pruefziffernberechnung.de, http://sunsite.berkeley.edu/SICI/sici.pdf