in reply to Re^2: Parsing a string from a file
in thread Parsing a string from a file
my @time = (1, 2, 3); my $counter = 5; my $data = { counter => $counter, time => \@time, }; my $s = 'Today is [% time.1 %] and you have seen this [% counter %] ti +me[% "s" IF counter > 1 %]!'; warn $s; use Template; my $template = Template->new(); my $out = ''; $template->process(\$s, $data, \$out) or die $template->error; warn $out; __END__ ~~~Output~~~: Today is [% time.1 %] and you have seen this [% counter %] time[% "s" +IF counter > 1 %]! at /tmp/t line 8. Today is 2 and you have seen this 5 times! at /tmp/t line 13.
|
|---|