Algori...M11_007(3pm)

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

πŸ’… Algori...M11_007(3pm) β€” aka the Algorithm::CheckDigits lore drop

okay bestie, so this whole thing lives in the User Contributed Perl Documentation, section 3pm, and it is genuinely the moment you needed for VAT Registration Numbers. no cap. πŸŽ€


✨ NAME ✨

CheckDigits::M11_007 β€” bestie, this thing literally computes check digits for VAT Registration Number (FI). that's the whole job. iconic behavior. πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

so here's the vibe check, fr fr:

use Algorithm::CheckDigits;

$ustid = CheckDigits('ustid_fi');

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

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

$cd = $ustid->checkdigit('13669598');
# $cd = '8'

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

like look at her. she's doing so much and she's making it look effortless. πŸ”₯


πŸ‘‘ DESCRIPTION πŸ‘‘

🌈 ALGORITHM β€” study time, babes

  1. Beginning left every digit is weighted with 7,9,10,5,8,4,2. okay so we go left to right and hand out these weights like friendship bracelets.
  2. The weighted digits are added. yes, all of them. math is mathing. ✨
  3. The sum from step 2 is taken modulo 11. the ✨modulo✨ moment.
  4. The checkdigit is 11 minus the sum from step 3. Is the difference 10, the number won't be taken. (like, she's rejected, we move on, it wasn't meant to be 😭) If the difference is 11, the checkdigit is 0. periodt.

🧚 METHODS 🧚

  • is_valid($number) β€” Returns true only if $number consists solely of digits and the rightmost digit is a valid check digit according to the algorithm given above. Returns false otherwise. it's giving strict queen. πŸ’…
  • complete($number) β€” The check digit for $number is computed and appended to the end of $number. Returns the complete number with check digit or '' if $number does not consist solely of digits. she'll finish what you started, but she has standards. 🫢
  • basenumber($number) β€” Returns the basenumber of $number if $number has a valid check digit. Return '' otherwise. she's stripping it back to the main character. πŸ‘‘
  • checkdigit($number) β€” Returns the check digits of $number if $number has valid check digits. Return '' otherwise. just the lil guy at the end. 🌸

πŸ’€ EXPORT πŸ’€

None by default.

bestie do NOT expect anything to show up in your namespace. nothing. she's private. no cap. πŸ™ˆ

πŸ’œ AUTHOR πŸ’œ

Mathias Weidner, "<mamawe@cpan.org>"


🌟 SEE ALSO 🌟


okay that's the whole page, you ate. no crumbs left. πŸ’…βœ¨

and a lil sign-off for the girlies who read all the way β€” this was perl v5.36.0, dated 2022-10-13, dropping from Algori...M11_007(3pm) straight into your group chat. love her, respect her, go compute some check digits πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from