hi,
I've been using the HTML:Template for the page design in Perl.
but the stuff works for some time and not working for some time..
I couldn't find the problem,
Look at my code,and the template file content is,Code:#!d:/perl/bin/perl use HTML::Template; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; my @top = ( {namee=>'raju',job=> '3434'}, {namee=>'ramesh',job=> '234'}, {namee=>'rajesh',job=> '123'}, ); my $template = HTML::Template->new(filename => 'index.tmpl'); $template->param(top_sender=>@top); print "Content-Type: text/html\n\n", $template->output();
this is not working and rendering the following errorCode:<center> <body> <table align=center border=0 style="border:1px solid blue;" width=60%> <th colspan=2>Top 10 Senders</th> <tr><td>Sender</td><td>Count</td></tr> <tr> <tmpl_loop name="top_sender"> <td> Name: <tmpl_var name="namee"></td> <td>Job:<tmpl_var name="job"></td> </tmpl_loop> </tr> </table></body></center> </html>
But look at the following code it's working properly and i couldn't find much difference between the two.. sHTML::Template : Attempt to set nonexistent parameter 'top_sender' - this parameter name doesn't match any declarations in the template file : (die_on_bad_params => 1) at e:\LOGANA~1\html\sample.pl line 20
and the template file content is,Code:#!d:/perl/bin/perl -T use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; warningsToBrowser(1); # this should be put after printing the header; use CGI qw(:all); use HTML::Template; use POSIX; print header; print "Content-type: text/html\n\n"; my $template = HTML::Template->new(filename => 'sample.tmpl'); $template->param(EMPLOYEE_INFO => [{ name => 'Sam', job => 'programmer' }, { name => 'Steve', job => 'soda jerk dfds' },] ); print $template->output();
the above code is working nicely...Code:<body><center> Today is <TMPL_LOOP NAME=EMPLOYEE_INFO> Name: <TMPL_VAR NAME=NAME> <br> Job: <TMPL_VAR NAME=JOB> <p> </TMPL_LOOP>
Something awkward..
Some time ago i tried to print the html content using print and the code rendered some error and when i added an empty line after last code it worked... seems the perl is something complicated than other programming languages..![]()





Bookmarks