From: Guillaume Marcais Date: 2005-03-04T07:56:09+09:00 Subject: Re: How/Where is a Stream Stored? On Thu, 2005-03-03 at 05:26 +0900, Randy Kramer wrote: > I'm thinking that maybe a stream ("on" the input file?) might be a way to do > the backtracking (by moving the pos back from the current position, either > one character at a time or several (and then read forward to the first > space)). It depends on the type of stream. You can backtrack easily with a file, but you can't with non-seekable stream (like stdin, network socket, etc.). So using IO#seek would prevent your program to work as a UNIX filter (reading from stdin, writing to stdout). Might be or not be a great deal to you, your call... > I'm wondering how efficient an operation that is--are such stream operations > performed on the disk file itself, or is the stream somehow buffered in > memory and the operations performed there. (Or, am I hopelessly > confused? ;-) All disk operations on recent OS are cached. Backtracking a small amount is likely not to generate any disk activity. Guillaume.