To do this, just write a subroutine. The code below does not check the value and assumes that the numbers to be converted are always non-negative.
If your version of Perl is not updated enough to support the state keyword, then simply declare $symbols as the variable my at the beginning of the program
use strict; use warnings; use feature 'state'; print base36(1234567890123); sub base36 { my ($val) = @_; state $symbols = join '', '0'..'9', 'A'..'Z'; my $b36 = ''; while ($val) { $b36 = substr($symbols, $val % 36, 1) . $b36; $val = int $val / 36; } return $b36 || '0'; }
Output
FR5HUGNF
source share