Heidegger has asked for the wisdom of the Perl Monks concerning the following question:
Holy Monks,
I'm trying to use the Template::Toolkit module for a CGI application. Here's the code I use:
my $output = "Content-type: text/html\n\n"; my $file = 'index.html'; my $vars = { title => "Hello World\n" }; my $template = Template->new({ INCLUDE_PATH => 'C:/Apache2/htdocs/gelna/templates' } ); $output .= $template->process($file, $vars) || die "Template process + failed: ", $template->error(), "\n"; print $output;
The ouput from this code is this:
C:\Apache2\htdocs\gelna>perl index.cgi <HTML> <head> <title>This is an HTML example</title> </head> <body bgcolor="#ffffff"> <h1></h1> <hr> <center> © Copyright 2000 Me, Myself, I </center> </body> </html> Content-type: text/html 1
Thus, the HTML header goes after the template output. I can't make it go first. What am I doing wrong here? BTW, in the beginning I tried to use the CGI::Application together with it. And I also couldn't make the header go before the template processing output. The Template::Toolkit seems to process my template well. It's just the header that doesn't work. And the "1" value at the end of the output bothers me too.
Thank you.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Template::Toolkit + CGI header
by edoc (Chaplain) on Jun 02, 2003 at 07:09 UTC | |
Re: Template::Toolkit + CGI header
by tedrek (Pilgrim) on Jun 02, 2003 at 06:50 UTC | |
by Heidegger (Hermit) on Jun 02, 2003 at 07:10 UTC | |
by davorg (Chancellor) on Jun 02, 2003 at 11:12 UTC |