* Thomas Hurst <[EMAIL PROTECTED]> [2002-06-23 08:00]:
> If you still want to use a script but don't want to eat
> <filesize> * <structure overhead> and IO every invocation, you'll want
> to seek to somewhere random in the file and read until you get a
> complete line, ala (in Ruby):
> 
> begin
>         File.open(file) do |f|
>                 f.seek(rand(File.size(file)))
>                 f.gets
>                 puts f.gets
>         end
> rescue EOFError
>         retry
> end
> 
> This will, however, guarantee the first line will never be read, and
> choose longer lines over shorter ones.

I have a fortune file (standard strfile format) that I use, and
occasionally my vi modeline (line 1) comes up as a fortune.  This is an
ideal solution... ;)

(darren)

-- 
Most rock journalism is people who can't write interviewing people
who can't talk for people who can't read.
    -- Frank Zappa

Reply via email to