ISIN(3pm)
β¨ NAME β¨
Business::ISIN β bestie, it validates International Securities Identification Numbers π
πΈ VERSION πΈ
0.20 β yes she's an OG but she still slays β¨
π SYNOPSIS π
Okay so here's the vibe, copy-paste core:
use Business::ISIN;
my $isin = new Business::ISIN 'US459056DG91';
if ( $isin->is_valid ) {
print "$isin is valid!\n";
# or: print $isin->get() . " is valid!\n";
} else {
print "Invalid ISIN: " . $isin->error() . "\n";
print "The check digit I was expecting is ";
print Business::ISIN::check_digit('US459056DG9') . "\n";
}
look at her go π
π¦ REQUIRES π¦
- Perl5
Locale::CountryCarp
π DESCRIPTION π
So Business::ISIN is a whole class, and what she does is validate ISINs (International Securities Identification Numbers). Think of them as the code that IDs shares, the same way an ISBN IDs a book π β iconic behaviour, honestly.
An ISIN is literally built like this, no cap:
- two letters β they tell you the country of origin of the security, following ISO 3166 π
- nine characters that live in
[A-Z0-9] - a decimal check digit at the end
Now the methods, one by one, because we don't gatekeep π«Ά
The new() method constructs a brand-new ISIN object. If you hand it a scalar argument, she'll use that argument to initialize the object's value. But listen β no attempt is made here to check that the argument is valid. She's just taking your word for it π
The set() method sets the ISIN's value to whatever scalar argument you give her. And same thing: no attempt is made to check that the argument is valid. Good news though β she returns the object, so you can chain like this: $isin->set("GB0004005475")->is_valid β¨
The get() method returns a string. If the ISIN is syntactically valid, you get the ISIN's value; otherwise you get undef. And interpolating the object reference inside double quotes does the exact same thing (peep the synopsis above, it's giving π
).
The is_valid() method returns true if the object holds a syntactically valid ISIN. Heads up bestie: that does not guarantee a security with that ISIN actually exists, okay? It's just syntax. Anything else and she returns false.
If the object does contain an invalid ISIN, the error() method returns a string explaining what's wrong. Like any one of these:
'xxx' does not start with a 2-letter country code'xxx' does not have characters 3-11 in [A-Za-z0-9]'xxx' character 12 should be a digit'xxx' has too many characters'xxx' has an inconsistent check digit
Otherwise, error() returns undef.
And then there's check_digit() β important: she's an ordinary subroutine, not a class method, okay? You hand her a string of the first eleven characters of an ISIN (for example US459056DG9), and she hands back the matching check digit, calculated with the so-called 'double-add-double' algorithm. Math queen π₯
π DIAGNOSTICS π
check_digit() will croak with the message 'Invalid data' if you pass her an unsuitable argument. So likeβ¦ don't do that π
π ACKNOWLEDGEMENTS π
Big love to Peter Dintelmann (Peter.Dintelmann@Dresdner-Bank.com) and Tim Ayers (tim.ayers@reuters.com) for the suggestions and for helping debug this module. Real ones π«Άβ¨
π AUTHOR π
David Chan <david@sheetmusic.org.uk>
β COPYRIGHT β
Copyright (C) 2002, David Chan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay that's the whole page bestie, you ate π β¨
this lil doc lives in the User Contributed Perl Documentation collection, came with perl v5.36.0, and got its timestamp 2022-11-21 β so it's ISIN(3pm), periodt ππ¦π
π¦ where this page comes from
- debian bookworm: libbusiness-isin-perl 0.20-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libbusiness-isin-perl 0.20-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbusiness-isin-perl 0.20-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbusiness-isin-perl 0.20-3 Β· 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