Algori...M11_011(3pm)
β¨ Algori...M11_011 π
(that's the 3pm perl manual page, bestie)
okay so this whole page lives in the User Contributed Perl Documentation section of the perl man pages, and honestly? it's giving "weird little Dutch tax number math" and I'm obsessed. let's get into it π«Ά
π NAME π
CheckDigits::M11_011 β bestie, this module computes check digits for the VAT Registration Number, aka the one from the NL (Netherlands). π§
π¦ SYNOPSIS π¦
here's the whole vibe, no notes:
use Algorithm::CheckDigits;
$ustid = CheckDigits('ustid_nl');
if ($ustid->is_valid('123456782')) {
# do something
}
if ($ustid->is_valid('123456782B04')) {
# do something
}
$cn = $ustid->complete('12345678');
# $cn = '123456782'
$cn = $ustid->complete('12345678.B04');
# $cn = '123456782B04'
$cd = $ustid->checkdigit('123456782');
# $cd = '2'
$cd = $ustid->checkdigit('123456782B04');
# $cd = '2'
$bn = $ustid->basenumber('123456782');
# $bn = '12345678';
$bn = $ustid->basenumber('123456782B04');
# $bn = '12345678.B04';
like⦠look at her go ⨠every value is right there, character for character, don't touch them.
πΈ DESCRIPTION πΈ
okay so this VATRN? it has 12 "digits" β except not all of them are digits, which is the plot twist π
- the third last one has to be a
Bπ - the fourth last one is the checkdigit π
- and the last two digits? no idea what they mean, and I'm not gonna pretend. genuinely, the author says "I don't know anything about the meaning of the last two digits." and honestly? same energy, we respect the honesty π
you can compute the checkdigit with this module using the whole VATRN, or literally just the first eight digits. your call, bestie π
π ALGORITHM π
the math is lowkey simple and highkey iconic, here's the whole ritual:
- Beginning right with the digit before the checkdigit, all digits are weighted with their position. I.e. the digit before the checkdigit is multiplied with
2, the next with3and so on. π₯ - The weighted digits are added. β
- The sum from step 2 is taken modulo
11. π - If the sum from step 3 is
10, the number is discarded. π (yes, that's a hard no, bestie β no check digit for you)
π METHODS π
four methods, all main character energy, let's go:
is_valid($number)β returns true only if the first eight positions of$numberconsist solely of digits (maybe followed by'B'and to further digits) and the eighth digit is a valid check digit according to the algorithm given above. β¨
Returns false otherwise. π
complete($number)β the check digit for$numberis computed and inserted at position eight of$number. π
Returns the complete number with check digit, or '' if $number does not consist solely of digits a dot and maybe 'B' at the ninth position. π
basenumber($number)β Returns the basenumber of$numberif$numberhas a valid check digit. π
Return '' otherwise. π
checkdigit($number)β Returns the check digits of$numberif$numberhas valid check digits. β
Return '' otherwise. π¦
π EXPORT π
None by default. not a single thing, we keep it minimal periodt π
π₯ SEE ALSO π₯
go read these too, iykyk:
perl,CheckDigits,www.pruefziffernberechnung.de,
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β thank you for your service, king π
π COPYRIGHT AND LICENSE π
Copyright 2004-2020 by Mathias Weidner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
real talk bestie, that means it's free software under the same terms as Perl itself β respect the license, always π«Ά
okay that's the whole page, you ate it, no crumbs π
this was perl v5.36.0, dated 2022-10-13, from the Algori...M11_011(3pm) file β mwah, go compute some Dutch VAT numbers, love u, bye! πΈπβ¨
π¦ 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