JenC wrote:
> OK, I see now it's not trivial to read and write from a file at the
> same time, and instead I should probably just drop to the command line
> and call
> `ruby -pe 'gsub(/foo/, "bar")' < myfile.vcproj`
> 
> When i do this, the text of the file spits out to stdio, and it
> appears the substitution has been made, but when I open the file in a
> text editor, it hasn't been changed.
> Am I missing something?
> I already checked file permissions and everything looks fine
> 
> Thanks,
> Jen
> 
> `

You'll want ruby -pie 'gsub(/foo/,"bar")'  myfile.vcproj

Or, if you want to keep a backup of the original (and you probably do, 
until you know this works the way you expect), you can add an extension 
of your choice to the -i flag:

ruby -p -i.bak e 'gsub(/foo/,"bar")'  myfile.vcproj

I've actually never used this on Windows, you'll have to try it and see.
-- 
Posted via http://www.ruby-forum.com/.