Hi monks!!

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.html
<!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>
action.cgi
#! C:\perl\bin\perl.exe use WebApp; my $webapp = WebApp->new(); $webapp->run();
WebApp.pm
use 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;
template.tt
<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. ;)

UPDATE

Thanks for everybody replied! I've found use NPH SCRIPTS could solve this question perfectly!


I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

In reply to Unwanted line (CGI question) by xiaoyafeng

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.