Busine...:Common(3pm)

πŸ“¦
version 0.0022 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Business::BR::Ids::Common πŸ’–

okay so bestie, gather round, because we're about to talk about Business::BR::Ids::Common β€” a little Perl module from the User Contributed Perl Documentation corner of the world (manual page Common(3pm), if you're keeping track πŸŽ€).


✨ NAME ✨

Business::BR::Ids::Common β€” common code used in Business-BR-Ids modules. that's it, that's the vibe πŸ¦‹


🌸 SYNOPSIS 🌸

use Business::BR::Ids::Common qw(_dot _canon_i _canon_id);
my @digits = (1, 2, 3, 3);
my @weights = (2, 5, 2, 6);
my $dot = _dot(\@weights, \@digits); # computes 2*1+5*2+2*3+6*3 = 36

# computes the sum of digits of ( 2*1, 5*2, 2*3, 6*3 )
# which is 2 + (1 + 0) + 6 + (1 + 8) = 18
my $s = _dot_10(\@weights, \@digits);

_canon_i(342222, size => 7); # returns '0342222'
_canon_i('12.28.8', size => 5); # returns '12288'

_canon_i(342222, size => 7); # returns '0342222'
_canon_i('12.28.8', size => 5); # returns '12288'
_canon_id('A12.3-B', size => 5); # returns 'A123B'

like, look at those comments doing the math for you. we love a self-documenting king πŸ‘‘


πŸ’… DESCRIPTION πŸ’…

so here's the tea: this module is meant to be private for Business-BR-Ids distributions. it's just a common placeholder for code that's shared among the other modules of the distribution. no gatekeeping, just shared utils 🫢

and ngl, the only code actually living in here right now is the computation of the scalar product between two array refs. that's the whole personality. and get this β€” in the future this module can disappear entirely, being more aptly named and even leaving the Business::BR namespace. it's giving "main character who might move away" 😭

πŸŽ€ _dot πŸŽ€

$s = _dot(\@a, \@b);

computes the scalar (or dot) product of two array refs:

sum( a[i]*b[i], i = 0..$#a )
heads up bestie: because of this definition, the second argument should be at least as long as the first argument. don't shortchange it πŸ’€

πŸŽ€ _dot_10 πŸŽ€

$s = _dot_10(\@a, \@b);

computes the product of corresponding elements in the array refs and then takes the sum of its digits. (used for computing IE/MG.) iconic behavior honestly ✨

πŸŽ€ _canon_i πŸŽ€

$qs = _canon_i($s, size => 8)

if the argument is a number, it formats it to the specified size. then, strips any non-digit character. if the argument is a string, it just strips non-digit characters. simple, clean, slay 🧚

πŸŽ€ _canon_id πŸŽ€

$qs = _canon_id($s, size => 8)

if the argument is a number, it formats it to the specified size. then, strips any non-digit character. if the argument is a string, it just strips characters matching "/[\W_]/". yes, the regex is different from _canon_i, don't come for me, that's just what it does πŸ”₯


🌈 EXPORT 🌈

  • None by default. you get nothing unless you ask, and honestly? respect the boundaries πŸ’œ

you can explicitly ask for "_dot()", which is a sub to compute the dot product between two array refs (used for computing check digits). there are also "_dot_10", "_canon_i" and "_canon_id" available to be exported on demand. so go off, request your faves 🌟


πŸ¦‹ SEE ALSO πŸ¦‹

please reports bugs via CPAN RT: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Business-BR-Ids

(that's a real link bestie, go click it if something's broken πŸ™ˆ)


πŸ‘‘ AUTHOR πŸ‘‘

A. R. Ferreira, <ferreira@cpan.org>


Copyright (C) 2005-2007 by A. R. Ferreira

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, no cap πŸ’– this was perl v5.36.0, dated 2022-10-13, from the Busine...:Common(3pm) page β€” mwah, periodt πŸ’…βœ¨

πŸ“¦ where this page comes from