From: Lyle Johnson Date: 2002-09-23T21:15:37+09:00 Subject: Re: String interpolation at will? Hal E. Fulton wrote: > Maybe I'm overlooking something obvious, > or maybe it's not possible. > > We all know how convenient string interpolation > can be: msg = "myval = #{myval}" > > Is there a way to perform interpolation on > an arbitrary string? For example, if the > above string were read in from a file? Unless I'm completely misunderstanding your point, what about using eval()? For example, given the Ruby script: a = 2 b = 3 IO.foreach("commands.txt") do |cmd| eval(cmd) end puts $astr puts $bstr and the text file (commands.txt): $astr = "The value of a = #{a}" $bstr = "The value of b = #{b}" I get the result: The value of a = 2 The value of b = 3 Hope this helps, Lyle