Algori...M09_001(3pm)
π CheckDigits::M09_001(3pm) π
okay so bestie, welcome to Algori...M09_001(3pm) β it's part of the User Contributed Perl Documentation, and it's literally the page that teaches you how to compute check digits for Euro notes. Euro. Banknotes. Yes we're doing money math, slay. πΈβ¨
π NAME π
CheckDigits::M09_001 β compute check digits for Euro notes π§
β¨ SYNOPSIS β¨
use Algorithm::CheckDigits;
$euro = CheckDigits('euronote');
if ($euro->is_valid('X07738250357')) {
# do something
}
$cn = $euro->complete('X0773825035'); # $cn = 'X07738250357'
$cd = $euro->checkdigit('X07738250357'); # $cd = '7'
$bn = $euro->basenumber('X07738250357'); # $bn = 'X0773825035'
like, that's the whole vibe. import it, build your checker with CheckDigits('euronote'), and then go off. π
π DESCRIPTION π
πΈ ALGORITHM πΈ
okay listen, the algorithm is short and it ate:
- Letters are replaced with their position in the alphabet ('A' = 1, ...). so
Xis not just a letter, it's a number now, periodt. π€ - The total of the digits of all numbers is computed. add it all up, no cap. β
- This sum is taken modulo 9. classic modulo moment. π
- The check digit is the difference between 8 and the number of step 3. so it's
8minus whatever you got, and that's your last digit. π
and fr fr, to validate: the last digit of the total of the digits of all numbers (including the check digit) must be8. that's the vibe check. if it's not8, it's not valid, sorry bestie. π
π¦ 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. (that trailing comma is in the original, iconic of it.) π«Ά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. π§©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. nothing gets exported unless you ask, and honestly? respecting the personal space. π
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β legend behavior, giving us the euro note math for free. π
π₯ SEE ALSO π₯
perl, CheckDigits, www.pruefziffernberechnung.de.
ngl the www.pruefziffernberechnung.de site is the check-digit lore archive, iykyk. π
and that's the page, bestie! this one's from perl v5.36.0, dated 2022-10-13, under the title Algori...M09_001(3pm) β¨ bye mwah ππ
π¦ 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