Use one of the various templating modules from CPAN:
use strict; use warnings; use Text::Template; my $template = Text::Template->new( TYPE => 'STRING', SOURCE => 'fred has {$color} eyes' ); our $color = 'blue'; print $template->fill_in;
use strict; use warnings; use HTML::Template; my $data = 'fred has <tmpl_var color> eyes'; my $template = HTML::Template->new( scalarref => \$data, ); $template->param( color => 'brown', ); print $template->output;
use strict; use warnings; use Template; my $data = 'fred has [% color %] eyes'; my $vars = { color => 'blue', }; my $tt = Template->new; $tt->process(\$data, $vars) || die $tt->error;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Re-Interpolating a Scalar (a string)
by jeffa
in thread Re-Interpolating a Scalar (a string)
by Nichodemus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |