in reply to CGI error with simple script

It is possibly a permissions problem in that the webserver user can't execute your script. Also, consider adding the following code, which may help you identify problems:

use CGI::Carp qw(fatalsToBrowser);

Update: Of course, the main thing wrong is that you don't print a header, which the browser needs. Do this before you print anything else:

print header();

Another update: Sigh. As [id://tirwhan] pointed out below, if you're using CGI.pm in the function-interface manner, you need to explicitly import the functions. This usually does it (you'll want to check CGI to make sure, though):

use CGI qw(:standard);

Replies are listed 'Best First'.
Re^2: CGI error with simple script
by tirwhan (Abbot) on Jan 10, 2006 at 18:47 UTC

    As ptum has already said, you need to print the HTTP header first. CGI.pm doesn't export the header subroutine into your namespace by default though, so you'll need to do one of these three things:

    use CGI; print CGI::header();
    use CGI qw(:standard); print header;
    use CGI; my $q = new CGI; print $q->header;

    Take a look at perldoc CGI as well, it contains a lot of functions which will make writing your dynamic pages easier.


    There are ten types of people: those that understand binary and those that don't.
      Thanks for the advice from both of you. Now it functions perfectly. I'll take a look into the perldoc, too.
Re^2: CGI error with simple script
by rndmtxt (Initiate) on Jan 10, 2006 at 18:43 UTC
    Thanks for the reply. I added that bit and rechecked the permissions. Unfortunately it still gave the same error and the permissions are 755. It's on my personal server, and there is a test script in the cgi-bin from the install that runs, so it has to be configured correctly.
Re^2: CGI error with simple script
by rndmtxt (Initiate) on Jan 10, 2006 at 18:45 UTC
    Oh, thank you very much.