mschout / perl-text-template

Expand template text with embedded Perl
13 stars 6 forks source link

Documentation error: example not working, HASH not used. #18

Closed nottledim closed 4 years ago

nottledim commented 4 years ago

This is elementary but it doesn't work.

`#!/usr/bin/perl

use Text::Template qw(fill_in_string);

my $text = fill_in_string( <<EOM, HASH=>{ 'recipient' => 'John' } ); Dear { $recipient }, Pay me at once. Love, G.V. EOM

print "$text\n"; `

the EOM in <<EOM must be enclosed in single quotes as in <<'EOM' (otherwise $recipient gets substituted by perl). If for example my $recipient = "Pete"; is set then the code appears to work but it doesn't. The substitution is not performed by Text::Template but by perl.

mschout commented 4 years ago

Patched, thanks!