Following is a perl script. It is running on shell when I go perl followed by the filename and works perfectly. But when I try to open it from browser, it gives back a 500. The permissions are fine because if i make some syntax error, it gives me the expected error message on browser screen:

#!/usr/bin/perl
use strict;
use CGI;
use CGI::Carp "fatalsToBrowser"; 
use DBI;
use LWP;

my $cgi = new CGI;

my $url = "http://www.google.com";

my $browser = LWP::UserAgent->new;

my $content = $browser->get($url);
print $cgi->start_html(), $cgi->header();

my $doc= $content->content();

if(length($doc) > 100)
{
	extractMeta($doc);
}

print $cgi->end_html(), "\n";

sub extractMeta()
{
	print "Inside subroutine";
	#Databse Information
}

Can someone tell me whats killing it in the browser??

The 500 is most likely caused by an error in your server setup rather than the code itself

The 500 is most likely caused by an error in your server setup rather than the code itself

Well, in that case, Its my college server. Someone must have crashed it! Thanks!!

What platform and web server is it running?

What platform and web server is it running?

I think its apache
2.0.63

the weird thing is its showing me syntax errors in the browser when i deleberately remove a semmi-colon or alike. But is not showing anything when everything is right. So i think it rules out the possibility of wrong permissions.

You need to print the header first, not second:

print $cgi->start_html(), $cgi->header();


should be:

print $cgi->header(), $cgi->start_html();

commented: :) +12
commented: Rightt on time! +1

You need to print the header first, not second:

print $cgi->start_html(), $cgi->header();


should be:

print $cgi->header(), $cgi->start_html();

Thanks, you were right!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.