The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

NAME

Math::BaseMulti - a perl module for creating identifiers with a per digit base

SYNOPSIS

$mbm = Math::BaseMulti->new(
digits => [
[ 0..9, 'A'..'Z' ],
[ 0..9, 'A'..'Z' ],
[ 0..9, 'A'..'Z' ],
[ 0..9 ],
],
);
$mbm->to( 10 ); # will return "10"
$mbm->to( 1000 ); # will return "2S0"
$mbm->from( 'BA0' ); # will return 133310
--
$mbm = Math::BaseMulti->new(
digits => [
[ 'S' ],
[ 'N' ],
[ 0..9,'A'..'F','H','J','K','M','N','P','R'..'Z' ],
[ 0..9,'A'..'F','H','J','K','M','N','P','R'..'Z' ],
[ 0..9,'A'..'F','H','J','K','M','N','P','R'..'Z' ],
[ 0..9,'A'..'F','H','J','K','M','N','P','R'..'Z' ],
[ 0..9,'A'..'F','H','J','K','M','N','P','R'..'Z' ],
[ 'A'..'Z' ],
],
leading_zero => 1,
);
$mbm->to( 0 ); # will return "SN00000A"
$mbm->to( 1 ); # will return "SN00000B"
$mbm->to( 1000 ); # will return "SN00017M"

DESCRIPTION

Math::BaseMulti can be used to create identifiers with a base defined per digit.

The module provides conversion to/from such identifiers.

METHODS

new()

Creates an object instance.

Accepts parameters 'digits' and 'leading_zero'. For description see methods below.

from()

Expects a string in the format of defined by the parameter 'digits' and converts it to an Int value.

to()

Expects an Int value and converts it to a string in the format defined by the 'digits' parameter.

digits()

Accepts an array of arrays.

Each element in the the first array repersents a digit. From high to low. (Little-Endian) Each subarray contains a list of possible characters. The value will be the index of the character in this array. first element => 0, second element => 1, ...

leading_zero()

Defines if to() should always add padding zeros values.

DEPENDENCIES

Math::BaseMulti requires Moose.

COPYRIGHT AND LICENSE

Copyright 2012-2013 by Markus Benning

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