Algori...M11_004(3pm)
π¦ NAME π¦
okay so this is the manual page for Algori...M11_004(3pm) β User Contributed Perl Documentation, bestie, and it's literally all about CheckDigits::M11_004, which computes check digits for CPF (BR) and Titulo Eleitoral (BR). that's it, that's the whole vibe. π
β¨ SYNOPSIS β¨
bestie here's the whole thing in action, no cap:
use Algorithm::CheckDigits;
$cpf = CheckDigits('cpf');
if ($cpf->is_valid('043.033.407-90')) {
# do something
}
$cn = $cpf->complete('043.033.407-');
# $cn = '043.033.407-90'
$cd = $cpf->checkdigit('043.033.407-90');
# $cd = '90'
$bn = $cpf->basenumber('043.033.407-90');
# $bn = '043.033.407-'
like, look at her go π
π DESCRIPTION π
πΈ ALGORITHM πΈ
the way this algorithm eats, fr fr β it goes like this:
- from left to right, every single digit gets multiplied by its position in the sequence. everyone gets a glow-up number, slay. β¨
- then you add up all those products. sum city. π₯
- then you take that sum from step 2 and mod it by 11. ok and then it splits:
a) if the result is 0 or 1, the checkdigit is 0
b) otherwise the checkdigit is 11 minus the result
- then that first checkdigit gets appended to the number and you go back and do steps 1 through 3 all over again. yes, again. it's giving round two, it's giving sequel. π
π«Ά METHODS π«Ά
is_valid($number)β this one only says true if$numberis solely numbers AND the last digit is a valid check digit per the algorithm above. otherwise? false. periodt.complete($number)β computes the check digit for$numberand smushes it onto the end of$number. returns the complete number with the check digit, or''if$numberisn't solely digits and spaces. πbasenumber($number)β hands you back the basenumber of$number, but only if$numberhas a valid check digit. otherwise it returns''. no notes.checkdigit($number)β gives you the checkdigit of$numberif$numberhas a valid check digit. otherwise it returns''. iconic behavior honestly.
π§ EXPORT π§
None by default. like, she's not gonna show up unless you ask her to, and that's valid. π
π AUTHOR π
Mathias Weidner, <mamawe@cpan.org> β the mastermind, the main character, the blueprint. π«Ά
π SEE ALSO π
perlCheckDigitswww.pruefziffernberechnung.de
lowkey if you're checking CPF or Titulo Eleitoral digits and you skip this page, that's on you bestie π
okay that's the whole page, and for the record this is the perl v5.36.0 version, dated 2022-10-13, and it lives on the Algori...M11_004(3pm) page. mwah, stay valid π π
β¨ππ¦πΈ
π¦ 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