next up previous contents
Next: Web Clients: the LWP Up: Perl on the Web Previous: User Information methods   Contents


Debugging CGI scripts

If there's an error in your CGI script, the error message will not be directly readable through the browser; instead, most web servers send a generic ``Error 500'' page, which provides little or no information about the nature of the problem. The actual text from the perl interpreter, which is displayed on standard error for non-CGI programs, is routed to the error log for the web server. If you're running your scripts on your own web server, this is just a minor inconvenience; if you are denied access to these error logs, however, it can make debugging a CGI script a difficult task.

Fortunately, the CGI module has a special offline mode for testing your perl CGI scripts before they are installed on the web server. To use the offline mode, simply invoke your CGI program as if it were a normal perl program. The CGI module will recognize that it's not being called by a web server, and will print the following message:

(offline mode: enter name=value pairs on standard input)
At this point, you can enter strings like the following:
     who = Fred%20Flintstone
to set the values of the form elements to whatever you'd like. Note that the encoding described in Section [*] is required when you use this mode, although if your input contains no blanks or special characters, no special action needs to be done. When you're finished entering the relevant name/value pairs, you can send an end of file signal (control-D on UNIX and control-Z on Windows) to terminate the program, and the output which would otherwise be sent to the web browser will be displayed on your screen.


next up previous contents
Next: Web Clients: the LWP Up: Perl on the Web Previous: User Information methods   Contents
Phil Spector 2002-10-18