Here is an example:
The template file:
HTML Code:
<html>
<head><title>Test Template</title></head>
<body>
<h3>My Header
<TMPL_LOOP NAME=LP>
<font color=green>Name :
Dept : <TMPL_VAR NAME=DEPT>
</TMPL_LOOP>
<br/>
<center>This is my footer
</body>
</html>
The Perl file:
Code: Perl
#!/usr/bin/perl
use CGI;
use CGI::Carp /warningsToBrowser fatalsToBrowser/;
use HTML::Template::Compiled compatible => 1;
use DBI;
$q = new CGI;
my $template = HTML::Template::Compiled->new(filename => 'tpl/test.tpl', die_on_bad_params => 0);
@loop_data = ();
$loop_data[0] = {'EMP_NAME'=>'Pradeep','DEPT'=>'Programming'};
$loop_data[1] = {'EMP_NAME'=>'Manindar','DEPT'=>'Accounts'};
$loop_data[2] = {'EMP_NAME'=>'Asha','DEPT'=>'Marketing'};
$loop_data[3] = {'EMP_NAME'=>'Tanaz','DEPT'=>'Programming'};
$template->param(LP=>\@loop_data);
print $q->header,$template->output;