Maybe this is too dangerous but

File.readlines("test.txt").each {|line| print eval('"' + line + '"')}

will work. Even if there were a function such as String.interpolate(str) it
would still be dangerous because any code within the #{} blocks would be
evaluated!

Steve

-----Original Message-----
From: Hal E. Fulton [mailto:hal9000 / hypermetrics.com]
Sent: Friday, September 20, 2002 2:54 PM
To: ruby-talk ML
Subject: String interpolation at will?


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?

gsub doesn't count. :) Unless you have a
particularly elegant way to use it.

Cheers,
Hal