in reply to Interpolating variables in a string

What are you trying to do?

Sometimes I use sprintf:

my $template = <<END_HERE; Hi, %s. I really like your %s shoes. Best, -- % END_HERE my $text = sprintf( $template, $name, $color, $sig );

Other times, closures work nicely to bind to various values:

my ($name, $color, $sig); my $template = sub { return <<END_HERE; Hi, $name. I really like your $color shoes. Best, -- $sig END_HERE }; $name = 'bob'; $color = 'blue'; $sig = 'c'; my $text = $template->();