From: Robert Dober Date: 2007-06-12T05:05:44+09:00 Subject: Re: Ruby way to update a file in place On 6/11/07, 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 via http://www.ruby-forum.com/. > No not necessarily, that depends how you can access the file, you can use Ruby as an inplace filter on a file ruby -i.bup -ne 'puts $_.gsub(/foo/,"bar")' somefile will edit somefile and create a backup copy somefile.bup of the original. Now when it comes to using files inside an application things are little bit more complicated :( HTH Robert > -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw