html - perl subroutine output appending "1" -
i'm playing sub routines. it's working should, i'm getting random returned value of: 1 @ bottom of page when call sub admin_view.
home.pl
#!/usr/bin/env -w perl no warnings 'experimental::smartmatch'; use cwd qw(abs_path); use feature qw(switch); use cgi::simple; use html::template; $cgi = cgi::simple->new; $action = $cgi->url_param('cmd') || ''; #set to: url/?cmd= $mode = $argv[0]; #accept entry terminal print $cgi->header; #make html appear if($action eq "") { #if url/?cmd= $mode = "home"; } if($action eq "admin_view") { #if url/?cmd=admin_view $mode = admin_view; } given($mode){ when(admin_view) { #html: admin mode & display posts use rawr::template qw(admin_view); print &admin_view; } when(home) { print "some home page"; } ##default message default { print "mode not implemented" } }
template.pm
package rawr::template; #template stuff use strict; use warnings; use exporter qw(import); use html::template; our @export_ok = qw(admin_view); sub admin_view { # open html template ##yuck hardcoded ok, works now. reason ../tmpl/admin_view.tmpl doesn't work $template = html::template->new(filename => '/srv/mydomain/www/rawr/tmpl/admin_view.tmpl'); # fill parameters $template->param(alias => "some user"); $template->param(content => "hardcoded content"); $template->param(date => "date - change me"); $template->param(title => "hardcoded - change me"); # send content-type , print template output print "content-type: text/html\n\n", $template->output; } 1;
admin_view.tmpl
<table border="1" id="container"> <tr> <td id="main_content"> <ul> <li onclick="showmenu(this)">!<b>profile</b> <ul> <li><a href="#">modify</a></li> <li> delete</li> <li> lock</li> <br> </ul> </li> <br> <tmpl_var name=alias> <br> <br> <tmpl_var name=dsp> <br> </td> <td id="main_content" class="opacity_box" > <b><tmpl_var name=title></b> <tmpl_var name=date> <br> <br> <tmpl_var name=content> <br> </td> </tr> </table>
the template outputs fine, @ bottom of page random output of 1 after last </table>
tag
</table>1
any solution issue? cheers
your 'admin_view' sub print.
thus don't need call this:
print &admin_view;
because doing so, it's printing sub's return code. result of last command without explicit return, shows print
successful.
try
admin_view;
(lose &
it's bad style)
Comments
Post a Comment