December 2002
Intermediate to advanced
496 pages
9h 40m
English
In Chapter 4, we learned that when things go disastrously wrong in a Perl program, the situation should be dealt with by terminating the program with the die() function. This function prints a message to the standard error output, cleans up nicely, and exits the program with a nonzero exit status.
In CGI programs, if the die() function is executed, we may think that the string passed to the function will end up in the browswer. However, standard error output is not sent on to the client that requested the CGI program; instead, it is written to the error log file (here, /var/www/logs/error_log). For instance, if the CGI program test.cgi contains this line:
open FH, ´/var/www/data/mydata.dat´ or die "File not opened: ...
Read now
Unlock full access