Algori...M16_001(3pm)
π CheckDigits::M16_001 β the ISAN check digit page (yes, that Algori...M16_001(3pm) one) π
okay bestie, gather round, because this is a Perl module page and it's genuinely so cute and useful. this one lives in the Perl docs as Algori...M16_001(3pm) β you know, the user-contributed Perl documentation corner. it's all about computing check digits for ISAN πΈ
β¨ NAME β¨
CheckDigits::M16_001 β computes check digits for ISAN π
π SYNOPSIS π
look at her. so clean. so iconic.
use Algorithm::CheckDigits;
$isan = CheckDigits('isan');
if ($isan->is_valid('123A567B8912E01A')) {
# do something
}
$cn = $isan->complete('123A567B8912E01');
# $cn = '123A567B8912E01A'
$cd = $isan->checkdigit('123A567B8912E01A');
# $cd = '4'
$bn = $isan->basenumber('123A567B8912E01A');
# $bn = '123A567B8912E01'
like. the math is mathing and the vibes are vibing. π¦
π§ DESCRIPTION π§
π₯ ALGORITHM π₯
bestie listen, this is the whole recipe and it is giving hexagons:
a(1) = 16
b(i) = a(i) % 17 +d(i), where d(i) is the decimal value of the hexdigit at position i.
c(i) = b(i) % 16
a(i) = c(i-1) * 2, for i greater than 1
- Beginning left for each i = 1..16,
a,b,care computed. - The check digit is the value for
d(16)wherec(16)equals 1. - The check digit is appended as hexadecimal value to the number.
not me readingaandbandcfour times to make sure i kept every single one π they're all there, promise. no cap.
π«Ά METHODS π«Ά
is_valid($number)β returns true only if$numberconsists solely of numbers and the last digit is a valid check digit according to the algorithm given above. Returns false otherwise,complete($number)β the check digit for$numberis computed and concatenated to the end of$number. Returns the complete number with check digit or''if$numberdoes not consist solely of digits and spaces.basenumber($number)β returns the basenumber of$numberif$numberhas a valid check digit. Return''otherwise.checkdigit($number)β returns the checkdigit of$numberif$numberhas a valid check digit. Return''otherwise.
π¦ EXPORT π¦
None by default.
(thats it. thats the whole export section. minimalism queen π)
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>"
π SEE ALSO π
perl, CheckDigits, www.pruefziffernberechnung.de.
okay and the little sign-off at the bottom of the page says it's perl v5.36.0, dated 2022-10-13 β so yeah, this page has been serving looks since then. go forth and validate those ISANs, bestie, you've got this fr fr πβ¨πΈ
π¦ 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