From: Todd Holloway Date: 2002-06-20T03:54:38+09:00 Subject: Re: in-place editing part two what if one needed to make several changes through out the file? ARGV.replace(['Makefile']) ARGF.each_line do |line| print line.sub(/blah1/, "blah2") print line.sub(/blah3/, "blah4") end this seems to give me the correct substitutions...but twice as many lines :) todd On Wed, Jun 19, 2002 at 08:22:09AM +0900, nobu.nokada@softhome.net wrote: > Hi, > > At Wed, 19 Jun 2002 07:31:53 +0900, > Ian Macdonald wrote: > > I'm trying to figure out why the following code chunk fails to edit my > > file in-place: > > > > $-i = '.foo' # set in-place edit mode > > mf = File.open('Makefile', 'r+') > > mf.each_line do |line| > > line.sub!(/-l\$\(RUBY_INSTALL_NAME\) /, "") > > end > > mf.close > > Inplace edit works for ARGF. > > ARGV.replace(['Makefile']) > ARGF.each_line do |line| > print line.sub(/-l\$\(RUBY_INSTALL_NAME\) /, "") > end > > -- > Nobu Nakada -- "This UI has been brought to you by the letters 'S' and 'K', and the runlevel 3." - Greg Andrews