To provide a smidge more detail, when your program "dies" it throws a plain ol' line of text to STDERR (Standard Error) and nothing to STDOUT. (For a CGI, STDOUT is the web browser.) Without anything sent to STDOUT, the web browser doesn't have anything to display, so you get an Error 500.
Before anything can be sent to the browser you first have to tell it what kind of data to expect. The "kind of data" (called the "MIME" type) is sent when you send the "Content-type" header, as in
print "Content-type: text/html\n\n";
# or, same thing but better
use CGI qw (:standard);
print header;
If a proper "Content-type" string isn't the
first thing your browser gets from your CGI you'll see a "error 500" just like you did. "Die" doesn't send a "Content-type" header when it sends it's error message, so voila, there's your problem.
virtualsue's suggestion to use CGI::Carp qw(fatalsToBrowser); is the solution. This causes any calls to "die" to be redirected to STDOUT, with the proper content-type header, allowing you to automagically see the content of your error message. It's very cool. Use it in good health.
Gary Blackburn
Trained Killer
Correction: Corrected STDOUT to STDERR. Ooops.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.