From: "Hal E. Fulton" Date: 2002-04-25T04:20:08+09:00 Subject: Re: My First Time > > The way I do this is something like: > > File.open(aFile, 'r') do |f| > tries = 0 > begin > # seek to a random point in the file > f.seek(rand(File.size(aFile))) > > # read to the next tagline > do > line = f.readline > until line == aSeperator [snippage before and after] This is clever, and I had wondered how you were jumping to a random place in a file of variable- length lines. However, for what it's worth, the fortunes will not have equal probability. The ones that have longer fortunes as their predecessors will be selected more often. OffTopic: This reminds me of the old puzzle about the guy who rode the subway for fun. There was an eastbound train that left on the hour and a westbound train that left fifteen minutes after the hour. (I.e., each train ran at precisely one-hour intervals.) He would always arrive at a random time and take the NEXT train to leave... yet in spite of the fact that the trains ran with equal frequency, he found himself taking the eastbound train three times as often as the westbound. (Get it?) Hal Fulton