Algori...ase_002(3pm)

πŸ“¦
version 1.3.6 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

CheckDigits::MBase_002 β€” bestie, this one computes check digits for blood bags (DE), BZUe (DE), and VAT Registration Number (DE). Yes, three whole vibes in one module. The manpage you're reading right now is filed under Algori...ase_002(3pm) (a little ✨truncated✨ for the terminal's convenience, iykyk).


🌸 SYNOPSIS 🌸

use Algorithm::CheckDigits;

$bb = CheckDigits('blutbeutel');

if ($bb->is_valid('2761011234567893')) {
      # do something
}

$cn = $bb->complete('276101123456789');
# $cn = '2761011234567893'

$cd = $bb->checkdigit('2761011234567893');
# $cd = '3'

$bn = $bb->basenumber('2761011234567893');
# $bn = '276101123456789';

Like, that's it. That's the whole entrance. Slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

🌟 ALGORITHM 🌟

Okay so here's the tea, step by step:

  1. Start with values P = 10, S = 0.
  2. Beginning left you do the following for all digits
    1. S = (P + digit) modulo 10
    2. If S is 0 then S = 10.
    3. P = (2 * S) modulo 11
  3. The check digit is (11 - P) modulo 10.

Periodt. That's the algorithm. πŸŽ€

πŸ’œ 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.

  • basenumber($number) β€” Returns the basenumber of $number if $number has a valid check digit.

Return '' otherwise.

  • checkdigit($number) β€” Returns the checkdigit of $number if $number has a valid check digit.

Return '' otherwise.

✨ EXPORT ✨

None by default. Not a thing. Zero. Nada. πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Mathias Weidner, "<mamawe@cpan.org>". Iconic behavior fr fr. πŸ’–


🌈 SEE ALSO 🌈

perl, CheckDigits, www.pruefziffernberechnung.de, www.eurocode.org.


k bye bestie, that's the whole page 🌸 β€” this little cutie is documented for perl v5.36.0, dated 2022-10-13, and lives under Algori...ase_002(3pm). Go forth and validate some blood bags. 🩸✨

πŸ“¦ where this page comes from