in reply to Re: die function error
in thread die function error

Unfortunately, I'm new to perl, and a little confused. What would cause the error. It only occurs when I hit the 'if routine.. I tried putting in use CGI::Carp; at the top of the script but no error was written to the error log. All I really want to do is print a message if the $max is exceeded and exit the script. Can you tell me how to replace the If.. statement to do the above??

Replies are listed 'Best First'.
Re: Re: Re: die function error
by shemp (Deacon) on Dec 03, 2002 at 22:39 UTC
    the perl die command prints to STDERR. normally, if you want some text to be sent back to the web page by your CGI script, use print, even if its a failure message. So:
    if ( error_condition ) { print error message to page; die error message to http server log; }
    (substitute appropriate text for the messages)
    CGI::Carp writes no error to the error log, because the errors are sent to STDOUT instead of STDERR.
    there may be flags to CGI::Carp to get the errors to STDERR also, but im no expert there...

    UPDATE:
    CGI::Carp does actually write to STDERR also, so that gets put in your error log too.