Click to See Complete Forum and Search --> : Getting useful errors from Perl?


lightnb
12-17-2008, 08:13 AM
I'm a PHP programmer, trying to debug a perl script ;)

I'm getting the message:
The server encountered an internal error or misconfiguration and was unable to complete your request. Your administrator may not have enabled CGI access for this directory. (I know that perl is configured correctly, it's just a parse error with the file, like a missing semi-colon or something.)

How do you set a Perl script to output PHP style errors, such as:
Unexpected something on line 76 in somefile.php?

dragle
12-17-2008, 10:25 AM
Are you sure the perl file has execute permissions? That's typically required.

Do you have access to your server error logs? You can find the actual error that perl is spitting out in there.

Do you have access to the console prompt of the server? You can syntax test the script with:
perl -wc scriptname.pl
If it (the script) is taint enabled, you'll need:
perl -Twc scriptname.pl
Finally, if you really want to display the error in the browser, you can add
use CGI::Carp qw(fatalsToBrowser);
to the top of the script; i.e.,
#!/usr/bin/perl -T

use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new();
print $cgi->header();

print 'This is a goof'
exit;

The above produces a message along the lines of
Software error:

syntax error at error.cgi line 12, near "exit"

Good luck!

lightnb
12-18-2008, 06:02 PM
Thanks, that's wonderful!

I'm a Linux user, so I can test right from my local machine. ;)