From: Robin Stephenson
Subject: Extracting a random line from a file in Emacs Lisp
Date: 
Message-ID: <52buj0x3qo.fsf@thames.elsevier.co.uk>
Could anyone tell me how to extract a random line from a file in Emacs
Lisp?  I've got some Perl code that does exactly what I want to do,
i.e. isn't dependent upon the length of the file:

#!/tool/bin/perl
srand;
rand($.) < 1 && ($it = $_) while <>;
print $it;

That's from the Camel book, by the way.
-- 
Robin Stephenson  (send email with subject `send pgp key' for my key)
Discontinue Use If Rash Persists
From: Gareth Rees
Subject: Re: Extracting a random line from a file in Emacs Lisp
Date: 
Message-ID: <yxsennwzrpv.fsf@stint.cl.cam.ac.uk>
Robin Stephenson <············@elsevier.co.uk> wrote:
> Could anyone tell me how to extract a random line from a file in Emacs
> Lisp?

The function `cookie' will do what you want.  If your file is not in the
standard fortune cookie format, you may need to set the variable
`cookie-delimiter' appropriately.

-- 
Gareth Rees