【问题标题】:Perl simple form and html problems,Perl 简单的表单和 html 问题,
【发布时间】:2013-07-06 05:16:07
【问题描述】:
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();

但它不起作用:/

【问题讨论】:

  • 这段代码在我的服务器上运行没有错误。您尝试在哪种类型的 Web 服务器上运行它?我的猜测是这是一个配置问题。您是否在此 Web 服务器上运行了其他 perl 脚本?如果是这样,它们运行没有问题吗?如果是这样,请查看其他脚本与您的脚本之间的差异。如果它们都没有运行,则需要更改服务器上的一些设置。
  • 另外,尝试从命令行运行它,看看你的输出是什么。您应该看到您的 html 标题和一些基本的 html 结构。如果您不明白,您至少可能会收到一条有用的错误消息。
  • 谢谢,我试试看,不胜感激
  • 虽然建议在 daxim 引用的答案中,但您的脚本未运行的原因应该存储在您的 Web 服务器的错误日志中(可能是 /var/log/apache2/error.log 或任何设置的 ErrorLog在您的/etc/apache*/*.conf 文件中)

标签: perl cgi


【解决方案1】:

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

【讨论】:

  • 对于任何感兴趣的人来说,这是因为在我的代码开始之前我有一个空间......不过感谢您的建议
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2016-08-31
    • 2011-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 2013-03-25
    相关资源
    最近更新 更多