Algori...M11_007(3pm)
π
Algori...M11_007(3pm) β aka the Algorithm::CheckDigits lore drop
okay bestie, so this whole thing lives in the User Contributed Perl Documentation, section 3pm, and it is genuinely the moment you needed for VAT Registration Numbers. no cap. π
β¨ NAME β¨
CheckDigits::M11_007 β bestie, this thing literally computes check digits for VAT Registration Number (FI). that's the whole job. iconic behavior. π
π¦ SYNOPSIS π¦
so here's the vibe check, fr fr:
use Algorithm::CheckDigits;
$ustid = CheckDigits('ustid_fi');
if ($ustid->is_valid('13669598')) {
# do something
}
$cn = $ustid->complete('1366959');
# $cn = '13669598'
$cd = $ustid->checkdigit('13669598');
# $cd = '8'
$bn = $ustid->basenumber('13669598');
# $bn = '1366959';
like look at her. she's doing so much and she's making it look effortless. π₯
π DESCRIPTION π
π ALGORITHM β study time, babes
- Beginning left every digit is weighted with
7,9,10,5,8,4,2. okay so we go left to right and hand out these weights like friendship bracelets. - The weighted digits are added. yes, all of them. math is mathing. β¨
- The sum from step 2 is taken modulo 11. the β¨moduloβ¨ moment.
- The checkdigit is
11minus the sum from step 3. Is the difference10, the number won't be taken. (like, she's rejected, we move on, it wasn't meant to be π) If the difference is11, the checkdigit is0. periodt.
π§ METHODS π§
is_valid($number)β Returns true only if$numberconsists solely of digits and the rightmost digit is a valid check digit according to the algorithm given above. Returns false otherwise. it's giving strict queen. πcomplete($number)β The check digit for$numberis computed and appended to the end of$number. Returns the complete number with check digit or''if$numberdoes not consist solely of digits. she'll finish what you started, but she has standards. π«Άbasenumber($number)β Returns the basenumber of$numberif$numberhas a valid check digit. Return''otherwise. she's stripping it back to the main character. πcheckdigit($number)β Returns the check digits of$numberif$numberhas valid check digits. Return''otherwise. just the lil guy at the end. πΈ
π EXPORT π
None by default.
bestie do NOT expect anything to show up in your namespace. nothing. she's private. no cap. π
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>"
π SEE ALSO π
perlCheckDigitshttp://www.pruefziffernberechnung.de/U/USt-IdNr.shtml#PZFI(german)
okay that's the whole page, you ate. no crumbs left. π β¨
and a lil sign-off for the girlies who read all the way β this was perl v5.36.0, dated 2022-10-13, dropping from Algori...M11_007(3pm) straight into your group chat. love her, respect her, go compute some check digits ππ¦π
π¦ 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