From: Todd Holloway Date: 2002-06-20T04:08:35+09:00 Subject: Re: in-place editing part two thanks...I had tried that, but I forgot the "!" in the previous line. todd On Thu, Jun 20, 2002 at 04:01:56AM +0900, Ian Macdonald wrote: > 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. > | > | > | -- "This UI has been brought to you by the letters 'S' and 'K', and the runlevel 3." - Greg Andrews