www.webdeveloper.com
Results 1 to 3 of 3

Thread: Getting useful errors from Perl?

  1. #1
    Join Date
    Jul 2006
    Posts
    249

    Getting useful errors from Perl?

    I'm a PHP programmer, trying to debug a perl script

    I'm getting the message:
    Code:
    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:
    Code:
    Unexpected something on line 76 in somefile.php
    ?

  2. #2
    Join Date
    Nov 2002
    Location
    Milan, MI
    Posts
    152
    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:
    Code:
    perl -wc scriptname.pl
    If it (the script) is taint enabled, you'll need:
    Code:
    perl -Twc scriptname.pl
    Finally, if you really want to display the error in the browser, you can add
    Code:
    use CGI::Carp qw(fatalsToBrowser);
    to the top of the script; i.e.,
    Code:
    #!/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
    Code:
    Software error: 
    
    syntax error at error.cgi line 12, near "exit"
    Good luck!

  3. #3
    Join Date
    Jul 2006
    Posts
    249
    Thanks, that's wonderful!

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles