我遇到了上述错误.
主要脚本如下
#!/opt/lampp/bin/perl use lib "/opt/lampp/htdocs/PERL"; use warnings; use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use WEBPAGE::PageDesign; use HTML::Form; my $header = get_header() ; my $html = parse_form(\%ENV); print "Content-type: text/html\n\n"; print <<HTML; $header $html HTML
生成的html是正确的,但是带有html页面的脚本后面跟着错误
Error message: <br />malformed header from script. Bad header=<body>: publish_scholarship.pl,
解决方法
将打印标题行移至顶部.如果它仍然无法工作,则将其移至BEGIN块.
use warnings; use strict; BEGIN { print "Content-type: text/html\n\n"; } use lib "/opt/lampp/htdocs/PERL"; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use WEBPAGE::PageDesign; use HTML::Form; my $header = get_header() ; my $html = parse_form(\%ENV); print <<HTML; $header $html HTML