Ruby - How to write a new file with output from script

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-03-13T05:08:19Z Indexed on 2010/03/13 5:15 UTC
Read the original article Hit count: 140

Filed under:

I have a simple script that does some search and replace. This is basically it:

File.open("us_cities.yml", "r+") do |file|
  while line = file.gets
  "do find a replace"
  end
  "Here I want to write to a new file"
end

As you can see I want to write a new file with the output. How can I do this?

© Stack Overflow or respective owner

Related posts about ruby