On Mon, 26 Mar 2001, Daniel Berger wrote: > > j,i = i,[0,i-4096].max > > f.reverse_each {|x| print x } > Worked like a charm. I don't know ruby well enough yet to completely > understand this code (the codeblock & proc.call are throwing me at the > moment) but I take it that you're reading in a max. of 4k per line. > Is that correct? Well, I'm reading a max of 4k at a time; there is no limit on the length of a line; the buffer grows bigger until the program knows that it has a full line. For very, very long lines, though, the program will become slower. I think that replacing i-4096 by i-4096-buf.length can do some good, but it also can do some bad and i don't know how the two would balance. There are of course a lot of other possible improvements. matju