Debugging CGI scripts can be a bit of a pain sometimes.
- you can write a script that filters out the extraneous junk from what's available in Apache's error_log
This dumps the structure to the error_log only. The webpage output is unaltered, and there's no indication to the user that any debug activity is occuring.
the O'Reilly book suggests running your CGI script from the command-line. That's all well and good, if your script doesn't take any parameters, or is otherwise easy to run from the command line.
But if your script is remotely complex, you can use this script to capture all inputs to a CGI script, when running under a webserver, and allows you to replay that 'input' when running under the command-line later.