my %wheel = {"One" => 8, "Two" => 1, "Three" => 1}; my $sum; my $item; foreach $item (keys %wheel) { $sum+=$wheel{$item}; } my $spin = int(rand($sum)); foreach $item (keys %wheel) { last if $sum < $wheel{$item}; $sum-=$wheel{$item}; } print "$item was picked\n";