Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!yale!mintaka!oliveb!orc!inews!mipos2!jsweedle From: jsweedle@mipos2.intel.com (Jonathan Sweedler) Newsgroups: comp.lang.perl Subject: random lines from a file Message-ID: <2067@inews.intel.com> Date: 10 May 90 02:00:05 GMT Sender: news@inews.intel.com Reply-To: jsweedle@mipos2.UUCP (Jonathan Sweedler) Distribution: usa Organization: Microprocessor Component Group, Intel Corp., Santa Clara, CA Lines: 10 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