CGI::Carp is always the first step. However, "use CGI::Carp qw(fatalsToBrowser);" occasionally does not provide everything you need to debug your script. If you have access to your servers error log, typing (in Linux, for example) tail error.log (or whatever your error log filename is, assuming you're in the log directory) will print out the last few lines of that log and may give you additional information.
If you are using the CGI module, you can try instantiating a CGI object and running the script from the command line.
#!/usr/bin/perl -wT
use strict;
use CGI;
my $query = new CGI;
When running the script from the command line, it will as you to enter name/value pairs in the format name=value. Enter all appropriate name/value pairs and hit cntl-d (cntl-z on Win32 systems) and the script will continue execution. Any errors will be directed to your terminal window.
Cheers,
Curtis | [reply] [d/l] |
Use CGI::Carp. Fatal errors (die) will then be sent to
your browser:
use CGI::Carp qw(fatalsToBrowser);
die "Fatal error messages are now sent to browser";
Also, make sure that you print out the correct HTTP headers. | [reply] [d/l] |
| [reply] |
Are you printing out the correct HTTP headers?
It wouldnt be an "error" persay if the page is just coming up blank, try checking your error log file for your web server, that can give out massive amounts of good information :), also try putting some debugging options in your script (it has nothing to do with a module), simply use pre tags (to make sure its not getting mixed up with other html) and spit out various variables and stuff..or at least thats what I would do.
-cleen | [reply] |
The foregoing suggestions are good ones. I also recommend
directing your errors to a separate log using carpout.
That way, you don't clutter up your error log too much,
and you don't have to grep for the program name (in the
case that other programs are writing to the error log at
the same time).
If you will be invoking multiple instances
of the program at the same time, don't forget to do file
locking on the carpout log! There's a recipe in <cite>The Perl Cookbook</cite>
about how to do this; in short, you want to use Fcntl qw (:flock);
and then use the flock function, which closely resembles
flock(2) from the Unix kernels.
TMTOWTDI, but ITYWLTW (I think you will like this way). ;)
Cheers.
| [reply] [d/l] [select] |
Sometimes you need to do a few more checks too. If you're using Netscape, then if you have a table open when the script dies then that table and anything in it wont show up. If you're using tables and Netscape and don't get content when you expect some, view the HTML source.
I don't use CGI.pm much (when I use Perl/Apache I like to write modules with mod_perl), so I'm not sure if things like CGI::Carp will automatically close tables for you.
Colin Scott
If you build it, they will be dumb...
| [reply] |