[Patrick Gundlach <clr1.10.randomuser / spamgourmet.com>, 2004-05-20 13.03 CEST]
> Dear ruby hackers,
> 
> I'd wonder if there is a simple method in searching backward in
> files. I want to read a pdf file, so I have to do the following:
> 
> 1) goto the end of file (pdffile.seek(0,IO::SEEK_END))
> 2) search backward for the string "%%EOF" within the last 1024 bytes
> 3) search backward for "startxref"
> 4) read the next bytes,.....
> 
> 
> Do I have to write my own seach backward routine or is there some
> functionality for it?

You can load the last 1024 characters in a string and use String#rindex for
(2). Then, use String#rindex again to find (3). If you don't find, load the
second-to-last 1024 characters, use String#rindex again, etc...

Good luck.

--