John W. Krahn [JWK], on Wednesday, March 30, 2005 at 12:56 (-0800) thoughtfully wrote the following:
JWK> You could use the Math::BaseCalc module: JWK> http://search.cpan.org/~kwilliams/Math-BaseCalc-1.011/ thanks, it is nice module, really easy to use. And also thanks to your program, but I have some questions: - my goal is 'convert' numbers to characters, so: my @digits = ( "a" .. "z", "A" .. "Z", 0 .. 9, "-", "_" ); 1 => 'a' 63 => '_' 64 => 'aa' 65 => 'ab' and so on. That module, and also your nice program get these result: 64 => 'ba' 65 => 'bb' I understand why it is so... So that means I lost some combination via base module like 'a*' and so on. I want this stuff to encode URLs, I have in database some numbers, get max number, encode it via this function, and have 'new url'. I know, there is lots stuff like this on the net, but I'd like to code my own for my project (it is not about compressing url, it is only feature:) So, if you could be so kind and if you have time, you can rewrite my program (surely could be improved) to get same results, here is the latest version I just wrote, also I did same speed improvements: use strict; use warnings; my $num = 10_000_000; # $a >= 0 my @chars = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9, '-', '_' ); my $all = @chars; print my $out = reverse(fn($num)); sub fn { my $num = shift; my $tmp = ($num/$all)-1; my $out = $chars[$num % $all]; $out .= $tmp >= $all ? fn($tmp) : $chars[$tmp] if $tmp >= 0; return $out; } -- ...m8s, cu l8r, Brano. [Dahlmer on cooking : Moo Goo Guy-In-A-Pan; Biscuits and G] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>