Algori...M10_003(3pm)

๐Ÿ“ฆ
version 1.3.6 ยท 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

CheckDigits::M10_003 โ€” the lil module that computes check digits for ISMN (that's the International Standard Music Number, bestie ๐ŸŽต).


โœจ SYNOPSIS โœจ

use Algorithm::CheckDigits;

$ismn = CheckDigits('ismn');

if ($ismn->is_valid('M-345-24680-5')) {
      # do something
}

$cn = $ismn->complete('M-345-24680');
# $cn = 'M-345-24680-5'

$cd = $ismn->checkdigit('M-345-24680-5');
# $cd = '5'

$bn = $ismn->basenumber('M-345-24680-5');
# $bn = 'M-345-24680'

๐ŸŒธ DESCRIPTION ๐ŸŒธ

๐Ÿงฎ ALGORITHM ๐Ÿงฎ

  1. That leading 'M' gets the value 3. Then, starting from the left, every number gets weighted alternatingly 3 and 1.
  2. Add up all those products. Sum city ๐Ÿ’…
  3. The sum from step 3 gets taken modulo 10.
  4. The check digit is the difference between 10 and the number from step 3, taken modulo 10.

๐Ÿซถ METHODS ๐Ÿซถ

  • is_valid($number) โ€” returns true only if $number is made up of nothing but numbers, and its last digit is a valid check digit according to the algorithm above. Anything else? It returns false. No cap.
  • complete($number) โ€” the check digit for $number gets computed and glued onto the end of $number. You get back the full number with its check digit โ€” or '' if $number isn't purely digits and spaces. Sorry babe ๐Ÿ˜ญ
  • basenumber($number) โ€” hands you the basenumber of $number, but only if $number has a valid check digit. Otherwise it returns ''.
  • checkdigit($number) โ€” gives you the checkdigit of $number, again only when $number has a valid check digit. Otherwise: ''. That's it, that's the vibe.

๐Ÿ“ฆ EXPORT ๐Ÿ“ฆ

None by default. Nothing. Nada. Zero. ๐Ÿ™ˆ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Mathias Weidner, "<mamawe@cpan.org>" โ€” absolute icon, we stan ๐Ÿ’œ


๐Ÿ”ฅ SEE ALSO ๐Ÿ”ฅ

perl, CheckDigits, www.pruefziffernberechnung.de.


okay that's the whole page, bestie, you ate it up fr fr โœจ This little legend shipped as part of User Contributed Perl Documentation under the manual page Algori...M10_003(3pm), generated with perl v5.36.0 on 2022-10-13 ๐ŸŽ€ Go forth and validate those music numbers ๐Ÿ’–๐ŸŽต๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from