Algori...MXX_003(3pm)

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

πŸŽ€ Algori...MXX_003 (3pm) πŸŽ€

okay bestie, pull up a chair because we're talking about CheckDigits::MXX_003 β€” it lives in the User Contributed Perl Documentation section of the manual, and it's a Perl module that handles check digits. slay. πŸ’…


✨ NAME ✨

CheckDigits::MXX_003 β€” she computes check digits for DEM. that's it, that's the job, and she does it flawlessly. periodt. πŸ‘‘


✨ SYNOPSIS ✨

here's the whole vibe, verbatim, don't touch a character:

use Algorithm::CheckDigits;

$dem = CheckDigits('dem');

if ($dem->is_valid('GD0645027K1')) {
      # do something
}

$cn = $dem->complete('GD0645027K');
# $cn = 'GD0645027K1'

$cd = $dem->checkdigit('GD0645027K1');
# $cd = '1'

$bn = $dem->basenumber('GD0645027K1');
# $bn = 'GD0645027K'

so like… you load the module, you grab a 'dem' checker, and then you just vibe with it. is it valid? complete it? pull the check digit? pull the base? all of it, no cap. πŸ¦‹


✨ DESCRIPTION ✨

πŸ’œ ALGORITHM πŸ’œ

ngl this one is a variation of the Verhoeff scheme β€” that's the whole teaser, and here's the step-by-step, zero steps skipped:

  • 0 β€” All letters are changed to numbers. every single one. πŸ₯°
  • 1 β€” All digits are permutated according to a permutation table.
  • 2 β€” The permutated digits are combined using a dieeder table. The first with the second, the result with the third, this result with the fourth and so on. it just keeps folding in, one at a time, like a girl group adding members. ✨
  • 3 β€” The result of the last combination in the dieeder table is in such a way combined that the result is 0 (zero). The number used for this combination is the checksum.
for details look at the source. that's what the docs say, and honestly? fair. πŸ”

πŸ’œ METHODS πŸ’œ

is_valid($number)

Returns true only if $number consists solely of numbers and the last digit is a valid check digit according to the algorithm given above.

Returns false otherwise,

complete($number)

The check digit for $number is computed and concatenated to the end of $number.

Returns the complete number with check digit or '' if $number does not consist solely of digits and spaces.

basenumber($number)

Returns the basenumber of $number if $number has a valid check digit.

Return '' otherwise.

checkdigit($number)

Returns the checkdigit of $number if $number has a valid check digit.

Return '' otherwise.


πŸ’œ EXPORT πŸ’œ

None by default. nothing sneaks into your namespace, she's polite like that. πŸ™ˆ


✨ AUTHOR ✨

Mathias Weidner, "<mamawe@cpan.org>" β€” shoutout to the icon who built this. πŸ‘‘


✨ THANKS ✨

(the section is there, but there's nothing listed under it) β€” an empty flex, we respect it. 😭


✨ SEE ALSO ✨

  • perl
  • CheckDigits
  • www.pruefziffernberechnung.de

🌸 gentle reminder bestie: the docs literally say for details look at the source, so if you're deep in the dieeder table trenches, the source is your bestie too. 🫢

and that's the whole page, mwah πŸ’–

sign-off time ✨ β€” this gem came from the User Contributed Perl Documentation, and the footer tells us it's perl v5.36.0, dated 2022-10-13. iconic. ate. no notes. πŸŽ€πŸ’œ

πŸ“¦ where this page comes from