http://www.perlmonks.org?node_id=158543


in reply to Re: Rolling a biased die
in thread Rolling a biased die

The algorithm is the generalised version of How do I pick a random line from a file?, so see there for an explanation.

--
Tommy
Too stupid to live.
Too stubborn to die.