Algori...M11_017(3pm)
π Algorithm::CheckDigits::M11_017 π
okay so bestie, this is Algorithm::CheckDigits::M11_017 β the section 3pm one, aka the Perl module that computes check digits for EC-No, EINECS and ELINCS. yes it's a mouthful. yes it's iconic. let's go π¦
β¨ SYNOPSIS β¨
use Algorithm::CheckDigits;
$ecno = CheckDigits('ecno');
if ($ecno->is_valid('200-236-6')) {
# do something
}
$cn = $ecno->complete('200-236-');
# $cn = '200-236-6'
$cd = $ecno->checkdigit('200-236-6');
# $cd = '6'
$bn = $ecno->basenumber('200-236-6');
# $bn = '200-236-'
like, look at her go π that's the whole vibe right there.
π DESCRIPTION π
πΈ ALGORITHM πΈ
the whole tea, in three little steps:
- going from left to right, every single digit gets multiplied by its position in the sequence. like a little lineup. everyone gets a number. no cap.
- you add up all those products. sum time. β¨
- that sum gets taken modulo 11. and the check digit? it's the last digit of the result. periodt.
π«Ά METHODS π«Ά
is_valid($number)β returns true only if$numberis made up of nothing but numbers and that last digit is a valid check digit according to the algorithm above. anything else? false. she's picky and honestly? valid. πcomplete($number)β computes the check digit for$numberand sticks it right onto the end. returns the complete number with the check digit, or''if$numberisn't purely digits and spaces. πbasenumber($number)β hands you the basenumber of$numberif$numberhas a valid check digit. otherwise it returns''. πcheckdigit($number)β hands you the checkdigit of$numberif$numberhas a valid check digit. otherwise, you guessed it:''. π
π EXPORT π
None by default. she gives you nothing for free, bestie. boundaβ I mean, boundaries. healthy ones. π
β AUTHOR β
Mathias Weidner, "<mamawe@cpan.org>" β we love a legend who signs their work. π«Ά
π SEE ALSO π
perlCheckDigitshttp://en.wikipedia.org/wiki/EC-No.
ok that's the page!! no missing options, no skipped steps, nothing snuck in that wasn't already there. that's the rule and we respect it. π₯
and that's a wrap, bestie π this whole thing is documented for perl v5.36.0, dated 2022-10-13 β so like, she's got a little history and she's still serving. go forth and validate those EC-Nos. slay. πβ¨
π¦ 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