Help for this page

Select Code to Download


  1. or download this
    my %bias = (1 => 1, 2 => 1);
    
  2. or download this
    $rand = $k if rand($sum += $v) <= $v; 
    # This simplifies to: 
    # $rand = 1 if rand(1) <= 1
    # this is always true.  That's wrong.
    
  3. or download this
    my $sum = 0;
    $sum += $_ foreach (values %bias);
    ...
            last;
        }
    }