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


in reply to geometric random distributions

int(log(1- rand)/log(1 - $p)) will give you a random integer from a geometric distribution with probability $p. $p must, of course, be between 0 and 1.