while( my($k,$v) = each %bias and not defined $rand){ $rand = $k if rand($biasbase{$k}) < $v; }