Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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;
like image 708
nicktendo Avatar asked Jan 25 '11 18:01

nicktendo


2 Answers

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.

like image 63
nicktendo Avatar answered Sep 21 '22 13:09

nicktendo


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.

like image 44
sahil Avatar answered Sep 21 '22 13:09

sahil