in reply to Invoke the Perl string interpolation engine on a string contained in a scalar variable.

If you have control over the format of the lines you want to interpolate into, I strongly suggest using a templating module and a "stash" of variables (such as a hash) rather than scalars which can only really be interpolated by string eval.
use Mojo::Template; my %vars = ( var1 => 'abel', var2 => 'baker', var3 => 'charlie', ); my $t = Mojo::Template->new(vars => 1); my $rendered = $t->render($text, \%vars);
There are many other options like Text::Template, Template::Toolkit, and Text::Xslate (which is designed to escape HTML by default, so you will want to configure it for type => 'text').
  • Comment on Re: Invoke the Perl string interpolation engine on a string contained in a scalar variable.
  • Download Code