David Masover
5/29/2008 12:49:00 AM
On Wednesday 28 May 2008 18:18:09 Cheyne Li wrote:
> I need "aaa=4" in the file instead of just print out
No offense, but this was pretty much handed to you. You should be able to get
the rest of the way yourself...
> >> print File.read('somefile').sub('aaa=100', 'aaa=4')
string = File.read('somefile').sub('aaa=100','aaa=4')
open('somefile','w'){|f| f.write string}
By the way: DON'T do it this way in a real program. It's not at all safe.
Learn about temporary files and file IO.