template2.cgi
############
#!c:/perl/bin/perl
use CGI qw(:all);
my $q = CGI->new;
print $q->header();
my @languages = (
{
language_name => 'Perl',
description => 'Practical Extraction and Report Language'
},
{
language_name => 'PHP',
description => 'Hypertext Preprocessor'
},
{
language_name => 'ASP',
description => 'Active Server Pages'
},
);
my $template = HTML::Template->new( filename => 'template2.tmpl' );
$template->param( language => \@languages ); # Array ref You have to pass => [ {a=>10, b=>20}, {a=>30, b=>40}, {a=>50, b=>60} ]
print $template->output();
template2.html
################
<head>
<title>Template 2</title>
</head>
<body>
<table>
<tr>
<th>Language</th>
<th>Description</th>
</tr>
<tmpl_loop name="language">
<tr>
<td><tmpl_var name="language_name"></td>
<td><tmpl_var name="description"></td>
</tr>
</tmpl_loop>
</table>
</body>
</html>
############
#!c:/perl/bin/perl
use CGI qw(:all);
my $q = CGI->new;
print $q->header();
my @languages = (
{
language_name => 'Perl',
description => 'Practical Extraction and Report Language'
},
{
language_name => 'PHP',
description => 'Hypertext Preprocessor'
},
{
language_name => 'ASP',
description => 'Active Server Pages'
},
);
my $template = HTML::Template->new( filename => 'template2.tmpl' );
$template->param( language => \@languages ); # Array ref You have to pass => [ {a=>10, b=>20}, {a=>30, b=>40}, {a=>50, b=>60} ]
print $template->output();
template2.html
################
<head>
<title>Template 2</title>
</head>
<body>
<table>
<tr>
<th>Language</th>
<th>Description</th>
</tr>
<tmpl_loop name="language">
<tr>
<td><tmpl_var name="language_name"></td>
<td><tmpl_var name="description"></td>
</tr>
</tmpl_loop>
</table>
</body>
</html>
No comments:
Post a Comment