Busine...:Common(3pm)
π 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 AND LICENSE πΈ
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
- ubuntu noble: libbusiness-br-ids-perl 0.0022-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbusiness-br-ids-perl 0.0022-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libbusiness-br-ids-perl 0.0022-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms