Algori...M97_002(3pm)
๐ NAME ๐
CheckDigits::M97_002 โ the lil module that computes check digits for the International Bank Account Number (aka IBAN) ๐ฆโจ
It lives in the Algori...M97_002(3pm) manual, and it is genuinely iconic, no cap.
๐ SYNOPSIS ๐
use Algorithm::CheckDigits;
$iban = CheckDigits('iban');
if ($iban->is_valid('DE88 2008 0000 09703 7570 0')) {
# do something
}
$cn = $iban->complete('DE00 2008 0000 09703 7570 0');
# $cn = 'DE88 2008 0000 09703 7570 0'
$cd = $iban->checkdigit('DE88 2008 0000 09703 7570 0');
# $cd = '88'
$bn = $iban->basenumber('DE88 2008 0000 09703 7570 0');
# $bn = 'DE00 2008 0000 09703 7570 0'
Bestie, look at that. She validates, she completes, she checkdigits, she basenumbers. Versatile queen ๐๐
โจ DESCRIPTION โจ
๐งฎ ALGORITHM ๐งฎ
Okay so here's the little routine, step by step. Pay attention, it's giving math but make it cute โจ
- First we gotta prep the IBAN number. The first two letters and the checksum get moved all the way to the right end. Then every letter gets substituted according to the substitute table ๐ธ, and the checksum is set to
'00'. - Take the whole number, hit it with modulo
97. - The checksum is the difference between
98and whatever step 1 handed you. - If the checksum is smaller than
10, a leading zero gets prepended. (Cute lil zero for padding, obsessed ๐)
๐ ๏ธ 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 above. Returns false otherwise. She's picky and honestly? deserved ๐complete($number)โ The check digit for$numbergets computed and concatenated onto the end of$number. Returns the complete number with check digit, or''if$numberdoesn't consist solely of digits and spaces.basenumber($number)โ Returns the basenumber of$numberif$numberhas a valid check digit. Returns''otherwise.checkdigit($number)โ Returns the checkdigits of$numberif$numberhas a valid check digit. Returns''otherwise.
๐ฆ EXPORT ๐ฆ
None by default. She's low maintenance like that ๐
๐ AUTHOR ๐
Mathias Weidner, "<mamawe@cpan.org>" โ absolute legend, fr fr ๐ซถ
๐ THANKS ๐
Detlef Pilzecker pointed out to me that there may be more letters as the first two in an IBAN number. He also made me aware of a faster method to compute the check number than using Math::BigInt. King behavior honestly ๐งโจ
๐ฆ SEE ALSO ๐ฆ
perlCheckDigitswww.pruefziffernberechnung.dewww.sic.ch/en/tkicch_home/tkicch_standardization/tkicch_financialinstitutions_ibanipi.htm
๐ Friendly reminder bestie: check digits are serious business, so always feed is_valid a string that actually fits the rules before you trust it with your whole banking vibe.
And that's the whole page, periodt ๐. This one shipped with perl v5.36.0 and got dated 2022-10-13, wrapped up in the Algori...M97_002(3pm) manual โ so if you ever forget where you read this masterpiece, iykyk ๐โญ
๐ฆ 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