Algori...M11_004(3pm)

πŸ“¦
version 1.3.6 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ¦‹ 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:

  1. from left to right, every single digit gets multiplied by its position in the sequence. everyone gets a glow-up number, slay. ✨
  2. then you add up all those products. sum city. πŸ”₯
  3. 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

  1. 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 $number is 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 $number and smushes it onto the end of $number. returns the complete number with the check digit, or '' if $number isn't solely digits and spaces. πŸ’–
  • basenumber($number) β€” hands you back the basenumber of $number, but only if $number has a valid check digit. otherwise it returns ''. no notes.
  • checkdigit($number) β€” gives you the checkdigit of $number if $number has 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 🌈

  • perl
  • CheckDigits
  • www.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