malformed header from script. Bad header=<!DOCTYPE html>
I am receiving the following server error on a perl script:
malformed header from script. Bad header=: youtube_perl.pl,开发者_开发百科
Here is my source code:
#!"C:\XAMPP\perl\bin\perl.exe" -T
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use WWW::Mechanize;
my $q = CGI->new;
my $url = 'http://www.youtube.com';
my $mechanize = WWW::Mechanize->new(autocheck => 1);
$mechanize->get($url);
my $page = $mechanize->content();
print $page;
Figured it out. Had to add the following before I attempted to print the page:
print "Content-type: text/html\n\n";
I guess perl can not print html pages without defining the header first.
print "Content-type: text/html\n\n";
Use \n\n
without this it will not print anything it will give:
Malformed header from script error
In your error log file.
精彩评论