Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My perl script returns a 500 server error

Debugging

My perl script returns a 500 server error

by  lilstevey  Posted    (Edited  )
First try the other suggestions in faq452-3023

Theres a handy little trick for situations like this.

Get rid of the content-type:text/html line, and put the following at the start of your script:

Code:
#!/usr/bin/perl

BEGIN
{
    print "Content-type: text/html \n\n";
}

my @code = ( <DATA> );

my $code = join "\n",@code;

eval $code;

print "Error : ".$@ if ( $@ );

__DATA__

Your script follows as normal here

This should work on a lot of simple scripts that you write yourself.

The way it works is by telling perl that your script ( the stuff after __DATA__ ) isn't perl, but data, so when perl first runs, it'll make no effort to understand it. Then, this data section is turned into a string, and perl runs it using eval, which will hopefully catch the errors ( if $@ ), and print them out.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top