Joseph K. Myers

Sunday, September 15, 2002

dice

The purpose of dice is simple: fairly choose a random line from input.

As described in the Perl Cookbook, every Nth line is given a 1/Nth chance of being picked. Whichever line remains after the end-of-file will be returned. Empty lines are not skipped.

Download:

dice (80 bytes)

Dice requires perl.

http://www.myersdaily.org/joseph/unix/dice.txt