Thank you. But my error_report function is located in a package,not the main script. for example,
package Myfunc; sub error_report { my($q,$msg) = @_; print $q->header(); # print or not print it?? print $msg; } 1; Then how to use a global variable for label it?Thanks. 2007/4/11, Tom Phoenix <[EMAIL PROTECTED]>:
On 4/10/07, Jen mlists <[EMAIL PROTECTED]> wrote: > How to judge whether I've output the http header or not where in cgi > scripts?Thank you. I think you're asking how a programmer can know whether or not the header has already been output when it's time to produce output (in an error-handling subroutine, say). Perhaps you want to use a global flag in your program; that's a simple solution. Or your error handler could simply output the header in any case, since it's an error message anyway. My preferred solution is to use an eval block that returns (rather than outputting) a complete web page. If everything worked, it's simple to output the page; otherwise, it's equally simple to output an error page. In either case, there's no worry about the headers until output time. Is that what you needed? --Tom Phoenix Stonehenge Perl Training
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/