our @VAL = ( 0 .. 9, 'a' .. 'z' ); # edit our %VAL = map { $VAL[$_] => $_ } 0 .. $#VAL; sub parseInt { my( $str, $base, $int ) = @_; $int ||= 0; $str =~ /^(.)(.*)$/ ? parseInt( $2, $base, $int * $base + $VAL{lc $1} ) : $int; } # parseInt sub toString { my( $int, $base ) = @_; $int > 0 ? (toString( int($int/$base), $base ) || '') . $VAL[$int % $base] : '0'; # edit } # toString