perlfaq nodetype
faq_monk
<P>
Here's an algorithm from the Camel Book:
<P>
<PRE> srand;
rand($.) < 1 && ($line = $_) while <>;
</PRE>
<P>
This has a significant advantage in space over reading the whole file in.
<FONT SIZE=-1>A</FONT> simple proof by induction is available upon request
if you doubt its correctness.
<P>