in reply to Re: Die function misfunctions
in thread Die function misfunctions

I appreciate the detail you furnished. The first lines of the script are now:
#!/usr/bin/perl use CGI qw(:standard); print header; use CGI::Carp qw(fatalsToBrowser); $query = new CGI; etc....
I'm still getting that silly ol' Internal Server Error message.
laura.guimauve

Replies are listed 'Best First'.
Re: Re: Re: Die function misfunctions
by virtualsue (Vicar) on Apr 30, 2001 at 22:19 UTC
    Have you tried running it from the command line? If you are still getting a 500 error, it quite likely is due to a syntax error in your script. Whenever I tinker with one of my CGI programs I always run it quickly from the editor to see if I broke anything before trying it from a browser.

    I also suggest turning on warnings and taint mode via

    #!/usr/bin/perl -wT
    and enabling strict syntax checking like so
    use strict;
    Taint mode is essential for security reasons, whereas the other things are just plain good for your development as a perl programmer. For more info on these, there is a wealth of information on this site (or just keep asking questions). You should also read 'perldoc perlsec' since you are writing CGI code.
Re: Re: Re: Die function misfunctions
by Trimbach (Curate) on Apr 30, 2001 at 21:57 UTC
    FYI, if you use
    use CGI qw (:standard);
    that's using CGI.pm in "function" mode, meaning there is no need to instantiate an object to use all the nifty CGI features. This is why print header; works. The "header" function gets imported from CGI into your program by the qw(:standard) bit in "use CGI." There are plenty of docs for this in the POD for CGI.pm.

    The long and the short of it is: if you're using qw(:standard) don't bother using $query=new CGI. In fact, as I have discovered on a couple of occassions, doing so can even get you into trouble. :-(

    But that's probably not your problem. Whenever you get Error 500 messages it means that your web browser is not getting what it expects, which means your CGI is not providing good, properly header'd information. If you have fatalstobrowser turned on and you're still getting the error it means your program isn't even compiling properly. (If it compiled, FatalsToBrowser would kick in and tell you what was wrong.) To check compilation do a perl -c yourscript.cgi from the command line to root out any nasty syntax errors.

    Gary Blackburn
    Trained Killer

      Reply to y'all (with my thanks!) You're right, the program has syntax errors and is not compiling correctly. Even so, what does seem to do nice error logging, however, is the
      BEGIN { use CGI::Carp qw(carpout); open(LOG, ">mycgi-log.txt") or die "Unable to append to mycgi-log: $! "; carpout(*LOG); }
      script, which is catching and printing my errors in the file and isn't too much trouble to consult. I just can't get the fatalstoBrowser to kick in.

      Also, thanks for confirming the possible conflict with the $object designation and the qw(:standard) syntax.

      laura.guimauve

Re: Re: Re: Die function misfunctions
by isotope (Deacon) on Apr 30, 2001 at 21:41 UTC
    Can you look at the server's error log? I don't think it's the die at this point, maybe CGI::Carp isn't installed?

    --isotope
    http://www.skylab.org/~isotope/