learning perl -- not working for me

learning perl -- not working for me

Posted by: bostonrant
Posted on: 2006-07-07 08:49:00

Hey,
I just tried my first Perl script. it's called index.cgi and the code is:

#!/usr/bin/perl

print "Hello world!n";
exit;

I get a 500 Server error. Any help?

Re: learning perl -- not working for me

Posted by: guice
Posted on: 2006-07-07 09:28:00

Kill exit; and make sure to: chmod 755 index.cgi

Don't use exit unless you have to exit prematurely.

Re: learning perl -- not working for me

Posted by: iansealy
Posted on: 2006-07-07 10:41:00

As well as making your script executable (as mentioned by guice), you also need to print an HTTP header telling the browser what type of content it's about to receive. So, before your first print statement, put:

print "Content-type: text/htmlnn";

Re: learning perl -- not working for me

Posted by: guice
Posted on: 2006-07-07 11:03:00

oh yah! oops.....been too long since I've written CGI scripts. lol

Re: learning perl -- not working for me

Posted by: bostonrant
Posted on: 2006-07-11 08:05:00

Thanks for the tips. It works now :)

Tags: perl scripthello worldserver errorusrexitcgiheyindexhelp