#!/usr/local/bin/perl # kjv.index is a fixed length value flatfile # of offsets of starting lines in kjv.txt # (8 bytes each, including delimiter) # there are just under 100K of these lines #we pick a random offset out of that selection of lines # and then use that to look in the actual file print "Content-type:text/html\n\n"; $linecount = 99813; # count of lines in index file $linestoshow = 20; $range = $linecount - $linestoshow +1; srand; $which = int(rand($range)) * 8; open(INDEX,"kjv.index"); seek INDEX,$which, 0; $offset = ; close INDEX; open(READ,"kjv.txt"); seek READ,$offset,0; for($i = 0; $i < $linestoshow; $i++){ $line = ; $buf .= $line; } close READ; print <<__EOQ__;
$buf
__EOQ__