Math::BaseMulti - a perl module for creating identifiers with a per digit base
use Math::BaseMulti; $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"
Math::BaseMulti can be used to create identifiers with a base defined per digit.
The module provides conversion to/from such identifiers.
Creates an object instance.
Accepts parameters 'digits' and 'leading_zero'. For description see methods below.
Expects a string in the format of defined by the parameter 'digits' and converts it to an Int value.
Expects an Int value and converts it to a string in the format defined by the 'digits' parameter.
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, ...
Defines if to() should always add padding zeros values.
Math::BaseMulti requires Moose.
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.
To install Math::BaseMulti, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::BaseMulti
CPAN shell
perl -MCPAN -e shell install Math::BaseMulti
For more information on module installation, please visit the detailed CPAN module installation guide.