templates - Why does my Perl CGI program show the program code, not the output? -
code - test.cgi
#!/usr/bin/perl use strict; use warnings; use cgi::fasttemplate; $tpl = new cgi::fasttemplate("/some/directory"); $tpl->no_strict(); $tpl->define(main => "test.htm"); $tpl->assign(test_content=> "test"); $tpl->parse(content => "main"); $tpl->print('content');
template file
< html> < head> < title>test< /title> < /head> < body> $test_content < /body> < /html>
explain
why can't see desired output in browser? when navigate test.cgi file see actual code , not template. doing wrong?
you seeing code instead of output of program because haven't configured webserver execute program, defaulting serving file text/plain.
how configure depends on server software use. example, see apache 2.2 cgi docs.
second, shebang line missing. program should start with:
#!/usr/bin/perl
where /usr/bin/perl
path perl executable wish use.
additionally, , not contributing problem:
- you missing
use strict;
,use warnings;
. there should boilerplate in perl program using catch many problems. - your html document has no doctype, triggers quirks mode. suitable doctype should boilderplate in html document write.
Comments
Post a Comment