#!/usr/bin/perl use strict; use warnings; use Inline 'BC'; # Little languages are cool. sub base { my ($number, $base) = @_; my $r = mybase ($number, $base); # bc returns groups of digits separated by spaces # if the base is larger than 16. # Mangle the return value if the base is at most 36, # but leave it like it is if the base is above 36. if ($base > 16 && $base <= 36) { $r =~ s/([1-9][0-9])/chr(ord('A')+$1-11)/ge; $r =~ s/[0\s]+//g; } $r } use Inline 'BC'; print base(1000000,36), "\n"; __DATA__ __BC__ define mybase(a, b){ obase=b return(a) } KEKR