From: Art Gillespie Date: 2006-01-01T04:15:14+09:00 Subject: Re: Newb: Search & Replace Thanks for the replies, everyone. I wound up with def do_substitution( filename ) File.open("#{filename}.tmp", "w") do |ofile| File.open("#{filename}") do |file| file.each do |line| yield ofile, line end end end File.rename("#{filename}.tmp", "#{filename}") end Which is probably overkill for my needs, but got me learning about blocks and is flexible. And fun! Thanks again. Art On 12/31/05, Ryan Leavengood wrote: > On 12/31/05, Art Gillespie wrote: > > Hi all, > > > > I'm implementing build automation in Ruby as a 'learn Ruby' exercise. > > I wanted to post the following code and solicit feedback on any idioms > > I might have missed with regards to text processing with Ruby. The > > code works--I'm just wondering if it should be shorter, or smarter, > > or... > > That is nice and idiomatic from my perspective. In fact I've written > code much like that to do what you are doing. While there might be > various tricks and hacks to make it shorter, they probably aren't > needed. > > Ryan > >