Base36.pm

Summary
Base36.pm
BE4::Base36Base 36 converting tools.
B36 returning functions
encodeB10toB36Convert a base-10 number into base-36 (string).
indicesToB36PathConvert base-10 indices into a base-36 path (string).
B10 returning functions
encodeB36toB10Convert a base-36 number into base-10 (int).
b36PathToIndicesConverts a base-36 path into base-10 indices (x,y).

BE4::Base36

Exporter
BE4::Base36

Base 36 converting tools.  Do not instanciate.

Using

use BE4::Base36;
my ($i) = BE4::Base36::b36PathToIndices("E21") ; # returns 18217
my ($i,$j) = BE4::Base36::b36PathToIndices("3E/42/01") ; # returns [4032,18217]
my $b36 = BE4::Base36::encodeB10toB36(32674) ; # returns "P7M"
my $b36Path = BE4::Base36::indicesToB36Path(4032, 18217, 2) ; # returns "3E/42/01"
Summary
B36 returning functions
encodeB10toB36Convert a base-10 number into base-36 (string).
indicesToB36PathConvert base-10 indices into a base-36 path (string).
B10 returning functions
encodeB36toB10Convert a base-36 number into base-10 (int).
b36PathToIndicesConverts a base-36 path into base-10 indices (x,y).

B36 returning functions

encodeB10toB36

sub encodeB10toB36

Convert a base-10 number into base-36 (string).

Parameters (list)

numberinteger - The base-10 integer to convert.

Examples

  • BE4::Base36::encodeB10toB36(32674) returns “P7M”.
  • BE4::Base36::encodeB10toB36(156) returns “4C”.
  • BE4::Base36::encodeB10toB36(0) returns “0”.

indicesToB36Path

sub indicesToB36Path

Convert base-10 indices into a base-36 path (string).  If the base-36 indices are (ABCD,1234), the base-36 path (length 3) is “A1B2/C3/D4”.

Parameters (list)

i,jintegers - The base-10 indices to convert into a path.
pathlengthinteger - Number of subdirectories + the file.

Examples

BE4::Base36::indicesToB36Path(4032, 18217, 3) returns “3E/42/01”.

See also

encodeB10toB36

B10 returning functions

encodeB36toB10

sub encodeB36toB10

Convert a base-36 number into base-10 (int).

Parameters (list)

b36string - The base-36 integer to convert.

Example

BE4::Base36::encodeB10toB36(“F4S6”) returns 706038.

b36PathToIndices

sub b36PathToIndices

Converts a base-36 path into base-10 indices (x,y).  If the base-36 path is “A1/B2/C3”, the base-36 indices are (ABC,123).

Parameters (list)

pathstring - The base-36 path to convert into 2 base-10 indices

Returns

An integer list, (col,row).

Example

BE4::Base36::b36PathToIndices(“3E/42/01”) returns (4032,18217).

See also

encodeB36toB10

sub encodeB10toB36
Convert a base-10 number into base-36 (string).
sub indicesToB36Path
Convert base-10 indices into a base-36 path (string).
sub encodeB36toB10
Convert a base-36 number into base-10 (int).
sub b36PathToIndices
Converts a base-36 path into base-10 indices (x,y).
Close