in reply to Re: Resolving Imbedded Variables
in thread Resolving Imbedded Variables

A technique similar to your hash suggestion can make the eval approach secure from code-insertion mischief (I'm guessing this is what you meant by "prone to error"):
my $string = 'foo: $foo and bar: $bar\n'; print $string, "\n"; my $foo = "foozleberry pie"; my $bar = "barzleberry foo"; $string =~ s/(\$\w+)/$1/gee; print $string, "\n";
Update: A hash is still a better choice because it automatically restricts which variables will be substituted to a set that you specify, which is almost surely desirable.

Caution: Contents may have been coded under pressure.