Perl简单的形式和HTML问题,

时间:2012-01-27 22:20:45

标签: perl cgi

Server error!

The server encountered an internal error and was unable to complete your request.

Error message: 
Premature end of script headers: askName.pl

继承我的代码......

#!/usr/bin/perl

#askName.plx

#use 5.006;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI;

print "Content-type: text/html\n\n";

my $cgi = new CGI;

print"<html><head><title> Forms Intro! </title></head>"; print "<h1> Welcome, ",$cgi ->            
param('first'), " " , $cgi -> param('last'), "</h1>"; print"</html>";

我也尝试过像这样格式化

print $cgi -> header();
print $cgi -> start_html("Welcome");
print "<h1> Welcome, ",cgi -> param('first'), " " , $cgi -> param('last');, "</h1>";
print $cgi -> end_html();

但它不起作用:/

2 个答案:

答案 0 :(得分:0)

这通常是由于Perl CGI未设置为可执行文件。基本上程序根本没有运行。

答案 1 :(得分:0)

可能是您的perl不在正常目录中,因此请在顶部而不是#!/usr/local/bin/perl上尝试#!/usr/bin/perl。这可能有用。