tags:

views:

66

answers:

1

I'm trying to create a base template which then loads data depending on what actions are taken. I included ( required ) some pages which was fine but when I included another file which I got a 500 internal error. pasting the code straight in and it works fine:

Here's what I've got;

#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
require LWP::UserAgent;
use DBI;


    #deal with post requests
    require "perl/post-sort.pl";
    #loading stylesheets and javascripts
    require "header.pl";
    # bring in loggin js
    if( $arg{REQUEST_KEY} eq "") {
        require "javascript/js-main-login.pl";
    }
    print "</head> \n";
    print " \n";
    ...
    ...

perl/post-sort.pl

my %arg = ();
for (split /\&/, <STDIN>) {
   my ($key, $val) = split /=/;
   $val =~ s/\+/ /g;
   $val =~ s/%([0-9a-fA-F]{2})/chr(hex($1))/ge;
   $arg{$key} = $val;
}

Any help much appreciated.

+4  A: 

A 500 internal server error often indicates a bad or missing header. Make sure that in the included code, the first thing that gets printed (to the browser) is the header, or make sure that nothing gets printed and the original code will print out the right header.

Another possibility is that a file you are require'ing does not "return true as the last statement" (i.e., doesn't end with a 1;), which would cause your script to fail at compile-time and produce a 500 error.

Also see this apropos discussion on debugging CGI scripts from earlier today.

mobrule