| Next | Program Repair Shop | 37 |

print qq{
<HTML>
...
};
If this happens a lot, a template-based approach may be more suitable
print fill_template("order_thank_you.tmpl",
NAME => "Ms. Betty White", CITY => "Hartford",
STATE => 'CT', AMOUNT => 143.12,
PURCHASE => [ "Long Last Soft Shine Lipstick",
... ]);
sub fill_template {
my $template = shift;
my %data = @_;
local (*TMPL, $/);
open TMPL, "< $template"
or die "Couldn't open template file $template: $!; aborting";
my $text = <TMPL>;
no strict 'refs';
# %%var%% is replaced with $data{var}
$text =~ s/%%(\w+)%%/$data{$1}/g;
return $text;
}
Or use one of the CPAN template modules
Typical examples: Text::Template, Template Toolkit
Also about 28 (!) others
Then stick the HTML in a template file somewhere else
| Next | ![]() |
Copyright © 2006 M. J. Dominus |