As my last nodenewbie questions for web in perl[OT], I've studied Web development these day. After reading a great number of document intensively and hearing some monks' suggestionsRe: newbie questions for web in perl[OT], I decide to make use of CGI::Application to build my web.
It seems all OK so far except one minor thing:
Every page output by CGI will add one line 'Content-Type: text/html; charset=ISO-8859-1'.
yesterday, I ask for it on chatterbox. some guru say there is a redundant statement: header; in my script. But I double check it, the answer is no. Below is my test snippet:
index.htmlaction.cgi<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> <form action = "action.cgi" method = "POST"> <p> name <input type = 'text' name = "name" value = ""> </p +> <p> passwd <input type = 'password' name = "password" value = +""> </p> <p> <input type = 'submit' name = 'submit' value = "submit"> + </p> </form> </body> </html>
WebApp.pm#! C:\perl\bin\perl.exe use WebApp; my $webapp = WebApp->new(); $webapp->run();
template.ttuse strict; use warnings; package WebApp; use base qw(CGI::Application); use Template; use CGI::Application::Plugin::TT; sub setup { my $c = shift; $c->start_mode('mode1'); $c->run_modes( 'mode1' => 'do_stuff'); } sub do_stuff { my $c = shift; my $h = $c->query(); my $name = $h->param('name'); my %params = ( name => $name, ); $c->tt_process('template.tt', \%params); } 1;
<html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> [% name %] </body> </html>
Sadly, the wield line is still there!
I suspect my platform (M$ + IIS6.0) caused it without any reasons. Anybody could tell me whether my guess is right or not. I hope perl gurus could enlighten me.
Thanks in advance!!
BTW, I found many questions about CGI on Seekers of Perl Wisdom.(Unfortunately, I can't found the answer to my question) It appears CGI is big, dark and mysterious forest to newbie. ;)
UPDATEThanks for everybody replied! I've found use NPH SCRIPTS could solve this question perfectly!
In reply to Unwanted line (CGI question) by xiaoyafeng
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |