Algori...M23_001(3pm)
π NAME π
CheckDigits::M23_001 β bestie, this is the module that computes check digits for DNI (ES). That's the Spanish national ID number situation, and yes it's iconic.
So real quick, the manual name is Algori...M23_001(3pm) from the User Contributed Perl Documentation, but like... the actual module is CheckDigits::M23_001. Same girl, shorter name. π
β¨ SYNOPSIS β¨
Okay so this is literally how you use it, no cap:
use Algorithm::CheckDigits;
$dni = CheckDigits('dni_es');
if ($dni->is_valid('54362315K')) {
# do something
}
$cn = $dni->complete('54362315');
# $cn = '54362315K'
$cd = $dni->checkdigit('54362315K');
# $cd = 'K'
$bn = $dni->basenumber('54362315K');
# $bn = '54362315'
Look at that. Four little calls and you're done. We love a low-effort slay. π
πΈ DESCRIPTION πΈ
π§ ALGORITHM π§
- The checkdigit is the whole number taken modulo 23 and coded according to a keytable.
That's it. That's the algorithm. Modulo 23 and a keytable, periodt. π
π 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 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. Not a single thing gets exported unless you ask, and honestly? Boundaries. π«Ά
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β thank you for your service, king. π
β SEE ALSO β
perlCheckDigitswww.pruefziffernberechnung.de
Heads up bestie: those method descriptions say exactly what they say βis_validtalks about digits, andcompleteshrugs and mentions digits and spaces. That's straight from the source, so don't come for me. π
Okay that's the whole page!! This was documented in perl v5.36.0, dated 2022-10-13, and it lives under the User Contributed Perl Documentation for Algori...M23_001(3pm). Byeee, go validate some DNIs, you ate. πβ¨π¦
π¦ 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