From: William James Date: 2005-12-02T00:42:48+09:00 Subject: Re: What is the best way to edit a file to eliminate a line Mike Fletcher wrote: > steve_rubytalk wrote: > > William James wrote: > >> ruby -i.bak -ne 'print if $_ !~ /foo/' stuff.txt > > Coo... that's a new one to me... very nifty. > > > > Unfortunately, I mislead you... I want to transform a file from within a > > cgi script... which means I need to use standard out to generate other > > feedback to the user. Is a similar facility available within a ruby > > program without executing a new ruby process? > > File.new( "stuff.txt" ) do | f | > f.each do |line| > print unless line =~ /foo/ > end > end IO.foreach('stuff'){|s| print s unless s =~ /foo/}