hopefulcd has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I'm confused with this re-occurring error. Sometimes when I put a perl script online on my ISP's Apache servers, the script runs just fine. However, sometimes I simply copy, paste, change permissions to 0755 and upload a different file that should work just like the other, but it tells me INTERNAL SERVER ERROR. This happens with scripts that really should run the fine. Here's an example script that works fine, however the exact copy of this script fails.
#!/usr/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); print header; print start_html("Environment"); foreach my $key (sort(keys(%ENV))) { print "$key = $ENV{$key}<br>\n"; } my $value = cookie('koh'); print "\n<br>\nThe cookie <b>koh</b> contains <b>$value</b>\n<br><br>\ +n"; print end_html;
If anyone knows what could be the cause of these errors, It would be greatly appreciated.

Replies are listed 'Best First'.
Re: Apache / Perl help...
by moritz (Cardinal) on Jul 01, 2008 at 23:17 UTC
    Your best bet is to look into your ISP's error.log, or if you don't have access to that, ask one of the friendly admins at your ISP's to tell you what's in that magic file.

    The error messages there are pretty much always much more helpful than a sinmple "internal server error".

Re: Apache / Perl help...
by jethro (Monsignor) on Jul 02, 2008 at 03:21 UTC
    If you upload files from a windows box it might have to do with the different line endings in windows and unix. But then I would expect your scripts to always fail

    If you have a shell on the server, you might start the script on the command line there to test for the availablility of modules.

    Do you use -T always? Or only in the scripts that fail?

Re: Apache / Perl help...
by pjotrik (Friar) on Jul 02, 2008 at 07:44 UTC
    If you don't have access to the server's error log, try closing the code inside an eval to catch exceptions:
    #!/usr/bin/perl -wT eval { use strict; ... }; print "Died with $@\n" if ($@);