by decklin · 13y ago · 0 comments
rand($.) < 1 && ($line = $_) while <>;
We all know rand and while, but if you don't know perl the rest is hard.<> is a common way to read stdin, and the value is assigned to the $_ special variable.
The one I didn't know was $., the current input line number. In other words, its your loop index that automatically increments.