Algori...MXX_006(3pm)

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

πŸ’– NAME πŸ’–

ok so bestie, this is CheckDigits::MXX_006 β€” it computes check digits with the Verhoeff scheme ✨ no cap, that's the whole vibe πŸ¦‹

🌸 SYNOPSIS 🌸

use Algorithm::CheckDigits;

$verhoeff = CheckDigits('verhoeff');

if ($verhoeff->is_valid('14567894')) {
      # do something
}

$cn = $verhoeff->complete('1456789');
# $cn = '14567894'

$cd = $verhoeff->checkdigit('14567894');
# $cd = '4'

$bn = $verhoeff->basenumber('14567894');
# $bn = '1456789'

like literally just use it, grab your object with CheckDigits('verhoeff'), and you're in business πŸ’…


🧚 DESCRIPTION 🧚

πŸ‘‘ ALGORITHM πŸ‘‘

ok so here's the tea, step by step:

  1. Right to left, 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. πŸ”₯
  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. iykyk, the source is where it's at 🫢

πŸ’œ 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.

  • 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, nada, zero exports, she's mysterious like that πŸ™ˆ


πŸ¦‹ AUTHOR πŸ¦‹

Mathias Weidner, "<mamawe@cpan.org>" πŸ’Œ

🌈 THANKS 🌈

Jonathan Peters wrote Algorithm::Verhoeff from which I took the routine to compute the checkdigits. shoutout king, we stan πŸ‘‘

✨ SEE ALSO ✨


k that's the whole page bestie, mwah πŸ˜­πŸ’– this lovely little doc is from perl v5.36.0, dated 2022-10-13, and it lives under the name Algori...MXX_006(3pm) on the 3pm manual β€” go forth and validate some check digits, you got this fr fr πŸŽ€βœ¨

πŸ“¦ where this page comes from