[comp.lang.perl] random lines from a file

jsweedle@mipos2.intel.com (Jonathan Sweedler) (05/10/90)

What's the most efficient way to print out a random line from a file?
The only way I can think of to do this would be to read in the whole file
to figure out how many lines there are and then pick one of them randomly.
It seems there must be a better way... (assume the file changes frequently,
and can't have it's length pre-computed -- that would be too easy!!).

===============================================================================
Jonathan Sweedler, Microprocessor Design, Intel Corp.
UUCP: {decwrl,hplabs,oliveb}!intelca!mipos3!mipos2!jsweedle
ARPA: jsweedle%mipos2.intel.com@relay.cs.net