Algori...M11_003(3pm)
π Algori...M11_003 π (that's the 3pm perl section, bestie β User Contributed Perl Documentation vibes)
okay so. picture this: it's the GDR, you've got a PKZ number, and you need to know if its check digit is fr fr valid. that's literally this module. it's CheckDigits::M11_003, it computes check digits for PKZ (GDR), and it's giving β¨ niche-but-iconic β¨.
π NAME π
CheckDigits::M11_003 β compute check digits for PKZ (GDR)
no cap, that's the whole name. short. sweet. slays.
π¦ SYNOPSIS π¦
here's the whole vibe in one block, copy-paste ready:
use Algorithm::CheckDigits;
$pkz = CheckDigits('pkz');
if ($pkz->is_valid('150765400354')) {
# do something
}
$cn = $pkz->complete('15076540035');
# $cn = '150765400354'
$cd = $pkz->checkdigit('150765400354');
# $cd = '4'
$bn = $pkz->basenumber('150765400354');
# $bn = '150765400354'
see how $cn, $cd and $bn just pop out with their little comments? that's her. that's the whole module working exactly as advertised. periodt.
πΈ DESCRIPTION πΈ
β¨ ALGORITHM β¨
okay this is the math part and honestly? it eats. it's a 1-through-8 pipeline and every single step matters, so no skipping, bestie:
- The checkdigit is set to 0. starting from zero, humble queen.
- From right to left the digits are weighted (multiplied) with
2,4,8,5,10,9,7,3,6,1,2,4. - The products are added.
- The sum of step 3 is taken modulo 11.
- The value of step 4 is added to a multiple (0..9) of the weight of the checkdigit (2).
- The sum of step 5 is taken modulo 11.
- The checkdigit is the multiple of the weight of the checkdigit where the value of step 6 equals 10.
- If there can't be reached a value of 10 in step 6, the number cannot be taken as a PKZ.
β οΈ notice step 8, bestie. if step 6 never hits 10, that number is just not a PKZ. it's not "invalid-ish", it's flat-out not one. no cap.
To validate a PKZ apply steps 2 to 4 to the complete number.
that's it! the whole validation is just steps 2β4 on the full number. lowkey elegant.
π«Ά METHODS π«Ά
every one of these returns a real answer, and every one of these has a sad little '' waiting for you if things go wrong. let's meet them:
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,
π yes, that trailing comma is in the original. we keep the details exactly. it's canon.
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 and spaces.
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.
yup. nothing. it's not gonna dump a single symbol into your namespace unless you ask. respectful. iconic. π
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>"
he made this. we love him for it. π«Ά
π SEE ALSO π
perlCheckDigitswww.pruefziffernberechnung.de
go read those if you wanna go deeper, iykyk.
okay bestie that's the whole page!! π one last thing for the sign-off: this doc ships with perl v5.36.0 and it's dated 2022-10-13. so it's an elder gen z. still relevant. still slaying. now go validate some PKZ numbers, you absolute main character. πβ¨
π¦ 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