From: Ian Macdonald Date: 2002-06-20T04:01:56+09:00 Subject: Re: in-place editing part two On Thu 20 Jun 2002 at 03:54:38 +0900, Todd Holloway wrote: > 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 :) Just avoid the first print: ARGV.replace(['Makefile']) ARGF.each_line do |line| line.sub!(/blah1/, "blah2") print line.sub(/blah3/, "blah4") end Ian -- Ian Macdonald | Men of quality are not afraid of women for ian@caliban.org | equality. | | |