From: "lrlebron@..." Date: 2007-06-13T02:10:23+09:00 Subject: Re: Ruby way to update a file in place On Jun 12, 1:10 am, barjunk wrote: > On Jun 11, 6:23 pm, "lrleb...@gmail.com" wrote: > > > > > On Jun 11, 2:42 pm, Li Chen wrote: > > > > Hi all, > > > > I just wonder what is the Ruby way to update a file in place. Do I need > > > to open a temporary/new file for writing and then rename the temporary > > > file? > > > > Thanks, > > > > Li > > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > I've used the rio library for this before.http://rio.rubyforge.org/. > > The website has some very good examples on how to use it. > > > Luis > > That's a nice library...I didn't notice any thing about locking the > file object. I'm assuming that that would be done outside the use of > the rio object. > > I was also wondering if you thought you could use that library to read > files that have records that look like: > > start line 1 > line 2 > line 3 > end line4 > > and treat the above four lines as a record? > > Mike B. Here's an example of using rio require 'rio' rio('C://test').all.files('*.vb') do |f| rio(f)