Ing. Branislav Gerzo wrote:
John W. Krahn [JWK], on Thursday, March 31, 2005 at 01:56 (-0800) has
on mind:
JWK> Two different digits are converted to 0?
JWK> The same digit is converted to two different values?
qood questions; ok, I changed @chars to:
my @chars = ( 0 .. 9 );
now here is list of results:
0 = 0
9 = 9
10 = 00
11 = 01
100 = 90
110 = 000
1000 = 890
1110 = 0000
and so on. It is logical. In math is 01 == 1, but in my function it is
good I think, because I get 'extra' combinations I wanted to.
If you want "'extra' combinations" then you could use rand().
{ my @digits = ( "a" .. "z", "A" .. "Z", 0 .. 9, "-", "_" );
sub fn {
my $in = shift;
my $res = "";
do {
substr $res, 0, 0, $digits[ rand @digits ];
$in = int( $in / @digits );
} while $in;
return $res;
}
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>