in reply to Re: Finding a random position within a long string (Activeperl Build 822)
in thread Finding a random position within a long string (Activeperl Build 822)

FunkyMonkthis may do the trick

try:
my $percent = 10; my $string = 'A' x 1_000_000; for ( 1 .. $percent / 100 * length $string ) { my $pos = int rand length $string; substr( $string, $pos, 1 ) = '?'; } print $string =~ y/?//;
Sth. like this is the approach I initially took (and failed).

If you check that out (with a larger string), youll see the print-
out from the last line will approach 0xffff.

That means (I'm struggling to say this)
   In Activeperl/Win, the RAND_MAX of 
   the underlying clib is promoted 
   into perl?
Is this documented?

Regards & Thanks

mwa
  • Comment on Re^2: Finding a random position within a long string (Activeperl Build 822)
  • Download Code