On Thu, 1 Dec 2005 12:05:11 -0800, you wrote:
>[EMAIL PROTECTED] (Chris Wagner) graced perl with these words of
>wisdom:
>
>> Just for fun I did a little test.
>> for (1 .. 10000) {
>> my $fn = rand();
>> ++$dup and next if exists $num{$fn};
>> $num{$fn} = 1;
>> }
>> print scalar keys %num, " unique numbers. $dup duplicates produced\n";
>>
>
>Just for fun, I changed one of the lines in that to
>
>for (1 .. 1000000) {
>
>When I ran the modified script, I got 32768 unique numbers, with 967232
>duplicates! As 32768 is a power of 2, I'm wondering if there's a limit on
>the number of keys one may have in a hash.
No, it's a limit on the number of values rand() produces on Windows, as
this one-liner shows:
perl -MConfig -e "print $Config{randbits}"
randbits is the number of bits in the value produced by rand(); the
value is 15 in ActiveState Perl for Windows. If you want a better random
number generator, there are modules available on the PPM repositories;
search for "random".
--
Eric Amick
Columbia, MD
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs