In Ruby you can reference variables inside strings and they are interpolated at runtime.
For example if you declare a variable foo equals \"Ted\
foo
\"Ted\
Well, I second stesch's answer of using erb in this situation. But you can use eval like this. If data.txt has contents:
he #{foo} he
Then you can load and interpolate like this:
str = File.read("data.txt") foo = 3 result = eval("\"" + str + "\"")
And result will be:
result
"he 3 he"