Algori...M97_001(3pm)

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

πŸŽ€ Algori...M97_001(3pm) πŸŽ€

okay bestie, this is a page from the User Contributed Perl Documentation manual, and it's about CheckDigits::M97_001 β€” the module that does check digits for Belgian VAT Registration Numbers (BE). yes that's a lot of acronyms, no we're not scared of them πŸ’…


✨ NAME ✨

CheckDigits::M97_001 β€” compute check digits for VAT Registration Number (BE) πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole vibe, copy-paste ready:

use Algorithm::CheckDigits;

$ustid = CheckDigits('ustid_be');

if ($ustid->is_valid('136695962')) {
      # do something
}

$cn = $ustid->complete('1366959');
# $cn = '136695962'

$cd = $ustid->checkdigit('136695962');
# $cd = '62'

$bn = $ustid->basenumber('136695962');
# $bn = '1366959'

slay. it's giving "four methods, four little errands, zero drama" 🌸


πŸ”₯ DESCRIPTION πŸ”₯

⭐ ALGORITHM ⭐

the whole tea, in two steps, no skips:

  1. take the whole number (without the checksum) and do it modulo 97.
  2. the checksum is the difference of the remainder from step 1 to 97.

that's it. that's the algorithm. lowkey elegant fr fr.


πŸ’… METHODS πŸ’…

is_valid($number)

returns true if $number is made up of nothing but numbers, and the last digit is a valid check digit per the algorithm up above πŸ‘‘

a leading 'BE' before the numbers gets ignored, bestie β€” it's just vibes, not data.

returns false otherwise.

complete($number)

the check digit for $number gets computed and then concatenated onto the end of $number.

returns the complete number with the check digit, or '' if $number doesn't consist solely of digits and spaces 😭

and a leading 'BE' before the digits? ignored for the computation, but retained for the result. main character energy, it stays. ✨

basenumber($number)

returns the basenumber of $number, but only if $number has a valid check digit.

a leading 'BE' before the digits gets ignored and is not returned with the result β€” ghosted, honestly 🫢

returns '' otherwise.

checkdigit($number)

returns the checkdigits of $number, but only if $number has a valid check digit.

returns '' otherwise.


🌈 EXPORT 🌈

none by default. as it should be, honestly. nothing jumping out at you unprompted πŸ’œ


πŸ‘‘ AUTHOR πŸ‘‘

Mathias Weidner, "<mamawe@cpan.org>" πŸŽ€


🌸 SEE ALSO 🌸


and that's the whole page bb πŸ’– this was perl v5.36.0, dated 2022-10-13, filed under Algori...M97_001(3pm) β€” go forth and validate those Belgian VAT numbers, icon. periodt. πŸŒˆπŸ’…πŸ¦‹

πŸ“¦ where this page comes from