Algori...MXX_006(3pm)
π 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:
- Right to left, all digits are permutated according to a permutation table. π
- 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. π₯
- 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$numberconsists 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$numberis 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$numberif$numberhas a valid check digit.
Return '' otherwise.
checkdigit($number)β Returns the checkdigit of$numberif$numberhas 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 β¨
perlCheckDigits<http://www.cs.utsa.edu/~wagner/laws/verhoeff.html><http://www.cs.nmsu.edu/~cssem/Dickcheckdoc.pdf>
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
- 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