ISIN(3pm)

πŸ“¦
version 0.20 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

✨ 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::Country
  • Carp

πŸ’– 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:

  1. two letters β€” they tell you the country of origin of the security, following ISO 3166 🌍
  2. nine characters that live in [A-Z0-9]
  3. 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 (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