Xan Xann wrote:

> Paul Lutus wrote:

/ ...

>> Also "not tested!". That may seem obvious at this point.
> 
> It does not work!!!:
> wiki.rb:10: parse error, unexpected kEND

My original code was actually pseudo-code, unbeknownst to me. :)

------------------------------------------

#!/usr/bin/ruby

def substitute(source,dest,find,replace)
  data = File.read(source)
  result = data.gsub(/#{find}/,replace)
  File.open(dest,"w") { |f| f.write(result) } if data != result
end

substitute("temp.txt","result.txt","i","x")

temp.txt = "This is a test line."

result.txt = "Thxs xs a test lxne."

Tested, which I should have done in the first place.

-- 
Paul Lutus
http://www.arachnoid.com