【发布时间】:2014-10-02 03:19:25
【问题描述】:
我对 perl 很陌生,我正在尝试设置一个运行 perl 的 Web 服务器...
我确实使它与另一个脚本一起工作,但是使用这个我得到了这个错误:
服务器错误!
服务器遇到内部错误,无法完成 您的要求。
错误信息:头文件前的脚本输出结束:index.pl
如果您认为这是服务器错误,请联系网站管理员。
错误 500
localhost Apache/2.4.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11
这是我的脚本:
#!"C:\xampp\perl\bin\perl.exe"
use strict;
use warnings;
#Open file and define $pcontent as content of body.txt
open(FILE,"body.txt");
local $/;
my $pcontent = <FILE>;
close(FILE)
#Open file and define $ptitle as content of title.txt
open(FILE,"title.txt");
local $/;
my $ptitle = <FILE>;
close(FILE)
#open html code
print "Content-type: text/html\n\n";
print "<html>";
#set html page title
print "<head>";
print "<title>$ptitle</title>";
print "</head>";
print "<body>";
#set the <body> of the html page
if ($pcontent = ""){
print "
<H1>ERROR OCCURED!</h1>"
} else{
print $pcontent;
};
#close the html code
print "</body>";
print "</html>";
【问题讨论】: