Algori...ase_003(3pm)
π CheckDigits::MBase_003 π
okay so this page is Algori...ase_003(3pm) from the User Contributed Perl Documentation corner of the world, and it's all about computing check digits for SICI β that's a Serial Item and Contribution Identifier, bestie. yes, the same SICI you keep seeing in serials land. let's get into it π
πΈ NAME πΈ
CheckDigits::MBase_003 β compute check digits for SICI (Serial Item and Contribution Identifier). that's it, that's the whole assignment, and it ate. β¨
β¨ SYNOPSIS β¨
the vibe in code form, literally copy-paste it:
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-';
see how the check letter just appears? iconic behavior honestly π
π¦ DESCRIPTION π¦
π§ ALGORITHM π§
okay bestie, this is the math part, and no cap it's not scary, it's just seven little steps. watch:
- In the string describing the number, all letters (
A-Z) get replaced with numbers 10-35 accordingly. and all the other non-numbers? they get replaced by 36. every single one. π - Beginning right, the numbers at all odd positions are added. (yes, starting from the right. read it again if you need to, i'll wait π«Ά)
- 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 step 3 are added together.
- 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'#'.
periodt. that's the whole algorithm π
π METHODS π
is_valid($number)β Returns true only if the last letter is a valid check letter according to the algorithm given above.
Returns false otherwise. (note the comma in the original, we keep it, we respect it π)
complete($number)β The check letter for$numberis computed and appended the end of$number.
Returns the complete number with check letter, or ''. yeah, empty string if it's not happening. π
basenumber($number)β Returns the basenumber of$numberif$numberhas a valid check digit.
Return '' otherwise. (yes, the original says "Return", not "Returns", and we're keeping that exact energy β¨)
checkdigit($number)β Returns the check letter of$numberif$numberhas valid check digits.
Return '' otherwise.
π EXPORT π
None by default. nothing jumps into your namespace uninvited, and honestly? boundaries. π
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β absolute legend, authoring banger CPAN modules fr fr π
π SEE ALSO π
perlCheckDigitswww.pruefziffernberechnung.dehttp://sunsite.berkeley.edu/SICI/sici.pdf
and that's the whole page, bestie! π«Ά this lil doc is living in perl v5.36.0, dated 2022-10-13, filed under Algori...ase_003(3pm). go check some SICI digits, you've got this π
β¨
π¦ where this page comes from
- ubuntu noble: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libalgorithm-checkdigits-perl 1.3.6-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms