Algori...M10_008(3pm)
π CheckDigits::M10_008 β the SEDOL check digit situation π
okay bestie so this is CheckDigits::M10_008, a Perl module in the User Contributed Perl Documentation section (that's 3pm if you're keeping score π). Lowkey it's the one that computes check digits for Sedol (GB) and honestly? it ate. Let's get into it π¦
β¨ NAME β¨
CheckDigits::M10_008 β compute check digits for Sedol (GB). no cap, that's the whole job π
πΈ SYNOPSIS πΈ
the vibe check, in code form:
use Algorithm::CheckDigits;
$sedol = CheckDigits('sedol');
if ($sedol->is_valid('0123457')) {
# do something
}
$cn = $sedol->complete('012345');
# $cn = '0123457'
$cd = $sedol->checkdigit('0123457');
# $cd = '7'
$bn = $sedol->basenumber('0123457');
# $bn = '012345'
so iconic, so clean, she does exactly what she says on the tin π
π¦ DESCRIPTION π¦
okay so history moment, because context is everything bestie β¨
Prior to March 2004, SEDOL codes solely consisted of numbers. Since March 2004, SEDOL codes are a 7 character alphanumeric code. the glow-up was real π
The structure of the alphanumeric SEDOL codes is: one alpha character followed by 5 alphanumeric characters followed by the numerical check digit.
- Alpha characters are
B-Zexcluding vowels. - Alphanumerical characters are
0-9,B-Zexcluding vowels. - Numerical Characters are
0-9.
No SEDOL code will be issued without the first alpha character. Active numerical SEDOL codes issued prior to March 2004 remain valid. the OGs are grandfathered in, periodt π
π ALGORITHM π
here's the lore, step by step π§
- All characters are assigned a numerical value from 0 to 35 where the characters
'0'to'9'get 0 to 9,'B'to'Z'get 11 to 35 with the position of the vowels kept empty (for instance'D'gets 13,'F'gets 15). - Beginning left all numbers are weighted with
1,3,1,7,3,9 and 1(checkdigit) - The sum of all products is computed.
- The check digit is the difference of the sum from step 3 to the next multiple of 10.
yeah it says "step 3" inside step 3, that's just how the original rolls, we don't question the lore π the math still slaps.
π 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 and spaces.
This function always returns the SEDOL code in upper case.
basenumber($number)
Returns the basenumber of $number if $number has a valid check digit.
Return '' otherwise.
This function always returns the SEDOL base number in upper case.
checkdigit($number)
Returns the checkdigit of $number if $number has a valid check digit.
Return '' otherwise.
π EXPORT π
None by default. nothing, zero, zilch, she's mysterious like that π
π AUTHOR π
Mathias Weidner, "<mamawe@cpan.org>" β legend behavior, we love to see it π«Ά
β SEE ALSO β
perlCheckDigitswww.londonstockexchange.comMasterfile technical specifications V7.0.
and that's the whole page bestie!! π β¨ documented for perl v5.36.0, dated 2022-10-13 β stay slay, stay valid, and may your check digit always be correct π¦π π
π¦ 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