in reply to Per cents and Probabilities
$my $total=0; for( @$cats ){ my $p = $hash->{$_}; $cat = $_ if( rand($total+=$p)<$p ); } return $cat; [download]