[Thamesvalley-pm] generating HTML

Ismail, Rafiq (IT) Rafiq.Ismail at MorganStanley.com
Wed Oct 24 04:29:17 PDT 2007


> -----Original Message-----
> Sent: 19 October 2007 09:50
> To: ThamesValley Perl Mongers
> Subject: Re: [Thamesvalley-pm] generating HTML
> some great ideas, thanks.
> Andy (and everyone else) suggested templates which having 
> done a bit of digging looks to be an excellent suggestion 
> (from a perl celebrity it seems!).
For another perspective.  I'm rather keen on HTML::Template these days,
which Andy also mentioned.  The templating language itself is very
restricted and simple.

<tr><td><TMPL_VAR NAME="host"></td></tr>

Your script:
use HTML::Template;

my $template = HTML::Template->new(filename=>'yourtemplate.html');
my @templateData;

for my $host (@hosts) {
	push @templateData, { host=>$host }
$tempalte->param(HOSTS => \@templateData;

## print your http headers first and then

## Send rendered template to STDOUT


NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

More information about the Thamesvalley-pm mailing list