Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / CGI::Carp.3
.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "CGI::Carp 3"
.TH CGI::Carp 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
.SH "NAME"
\&\fBCGI::Carp\fR \- CGI routines for writing to the HTTPD (or other) error log
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& use CGI::Carp;
.Ve
.PP
.Vb 5
\& croak "We're outta here!";
\& confess "It was my fault: $!";
\& carp "It was your fault!";
\& warn "I'm confused";
\& die "I'm dying.\en";
.Ve
.PP
.Vb 2
\& use CGI::Carp qw(cluck);
\& cluck "I wouldn't do that if I were you";
.Ve
.PP
.Vb 2
\& use CGI::Carp qw(fatalsToBrowser);
\& die "Fatal error messages are now sent to browser";
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\s-1CGI\s0 scripts have a nasty habit of leaving warning messages in the error
logs that are neither time stamped nor fully identified. Tracking down
the script that caused the error is a pain. This fixes that. Replace
the usual
.PP
.Vb 1
\& use Carp;
.Ve
.PP
with
.PP
.Vb 1
\& use CGI::Carp
.Ve
.PP
And the standard \fIwarn()\fR, die (), \fIcroak()\fR, \fIconfess()\fR and \fIcarp()\fR calls
will automagically be replaced with functions that write out nicely
time-stamped messages to the \s-1HTTP\s0 server error log.
.PP
For example:
.PP
.Vb 3
\& [Fri Nov 17 21:40:43 1995] test.pl: I'm confused at test.pl line 3.
\& [Fri Nov 17 21:40:43 1995] test.pl: Got an error message: Permission denied.
\& [Fri Nov 17 21:40:43 1995] test.pl: I'm dying.
.Ve
.SH "REDIRECTING ERROR MESSAGES"
.IX Header "REDIRECTING ERROR MESSAGES"
By default, error messages are sent to \s-1STDERR\s0. Most \s-1HTTPD\s0 servers
direct \s-1STDERR\s0 to the server's error log. Some applications may wish
to keep private error logs, distinct from the server's error log, or
they may wish to direct error messages to \s-1STDOUT\s0 so that the browser
will receive them.
.PP
The \f(CW\*(C`carpout()\*(C'\fR function is provided for this purpose. Since
\&\fIcarpout()\fR is not exported by default, you must import it explicitly by
saying
.PP
.Vb 1
\& use CGI::Carp qw(carpout);
.Ve
.PP
The \fIcarpout()\fR function requires one argument, which should be a
reference to an open filehandle for writing errors. It should be
called in a \f(CW\*(C`BEGIN\*(C'\fR block at the top of the \s-1CGI\s0 application so that
compiler errors will be caught. Example:
.PP
.Vb 6
\& BEGIN {
\& use CGI::Carp qw(carpout);
\& open(LOG, ">>/usr/local/cgi-logs/mycgi-log") or
\& die("Unable to open mycgi-log: $!\en");
\& carpout(LOG);
\& }
.Ve
.PP
\&\fIcarpout()\fR does not handle file locking on the log for you at this point.
.PP
The real \s-1STDERR\s0 is not closed \*(-- it is moved to CGI::Carp::SAVEERR. Some
servers, when dealing with \s-1CGI\s0 scripts, close their connection to the
browser when the script closes \s-1STDOUT\s0 and \s-1STDERR\s0. CGI::Carp::SAVEERR is there to
prevent this from happening prematurely.
.PP
You can pass filehandles to \fIcarpout()\fR in a variety of ways. The \*(L"correct\*(R"
way according to Tom Christiansen is to pass a reference to a filehandle
\&\s-1GLOB:\s0
.PP
.Vb 1
\& carpout(\e*LOG);
.Ve
.PP
This looks weird to mere mortals however, so the following syntaxes are
accepted as well:
.PP
.Vb 5
\& carpout(LOG);
\& carpout(main::LOG);
\& carpout(main'LOG);
\& carpout(\eLOG);
\& carpout(\e'main::LOG');
.Ve
.PP
.Vb 1
\& ... and so on
.Ve
.PP
FileHandle and other objects work as well.
.PP
Use of \fIcarpout()\fR is not great for performance, so it is recommended
for debugging purposes or for moderate-use applications. A future
version of this module may delay redirecting \s-1STDERR\s0 until one of the
CGI::Carp methods is called to prevent the performance hit.
.SH "MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW"
.IX Header "MAKING PERL ERRORS APPEAR IN THE BROWSER WINDOW"
If you want to send fatal (die, confess) errors to the browser, ask to
import the special \*(L"fatalsToBrowser\*(R" subroutine:
.PP
.Vb 2
\& use CGI::Carp qw(fatalsToBrowser);
\& die "Bad error here";
.Ve
.PP
Fatal errors will now be echoed to the browser as well as to the log. CGI::Carp
arranges to send a minimal \s-1HTTP\s0 header to the browser so that even errors that
occur in the early compile phase will be seen.
Nonfatal errors will still be directed to the log file only (unless redirected
with carpout).
.Sh "Changing the default message"
.IX Subsection "Changing the default message"
By default, the software error message is followed by a note to
contact the Webmaster by e\-mail with the time and date of the error.
If this message is not to your liking, you can change it using the
\&\fIset_message()\fR routine. This is not imported by default; you should
import it on the \fIuse()\fR line:
.PP
.Vb 2
\& use CGI::Carp qw(fatalsToBrowser set_message);
\& set_message("It's not a bug, it's a feature!");
.Ve
.PP
You may also pass in a code reference in order to create a custom
error message. At run time, your code will be called with the text
of the error message that caused the script to die. Example:
.PP
.Vb 9
\& use CGI::Carp qw(fatalsToBrowser set_message);
\& BEGIN {
\& sub handle_errors {
\& my $msg = shift;
\& print "<h1>Oh gosh</h1>";
\& print "<p>Got an error: $msg</p>";
\& }
\& set_message(\e&handle_errors);
\& }
.Ve
.PP
In order to correctly intercept compile-time errors, you should call
\&\fIset_message()\fR from within a BEGIN{} block.
.SH "MAKING WARNINGS APPEAR AS HTML COMMENTS"
.IX Header "MAKING WARNINGS APPEAR AS HTML COMMENTS"
It is now also possible to make non-fatal errors appear as \s-1HTML\s0
comments embedded in the output of your program. To enable this
feature, export the new \*(L"warningsToBrowser\*(R" subroutine. Since sending
warnings to the browser before the \s-1HTTP\s0 headers have been sent would
cause an error, any warnings are stored in an internal buffer until
you call the \fIwarningsToBrowser()\fR subroutine with a true argument:
.PP
.Vb 4
\& use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
\& use CGI qw(:standard);
\& print header();
\& warningsToBrowser(1);
.Ve
.PP
You may also give a false argument to \fIwarningsToBrowser()\fR to prevent
warnings from being sent to the browser while you are printing some
content where \s-1HTML\s0 comments are not allowed:
.PP
.Vb 5
\& warningsToBrowser(0); # disable warnings
\& print "<script type=\e"text/javascript\e"><!--\en";
\& print_some_javascript_code();
\& print "//--></script>\en";
\& warningsToBrowser(1); # re-enable warnings
.Ve
.PP
Note: In this respect \fIwarningsToBrowser()\fR differs fundamentally from
\&\fIfatalsToBrowser()\fR, which you should never call yourself!
.SH "CHANGE LOG"
.IX Header "CHANGE LOG"
1.05 \fIcarpout()\fR added and minor corrections by Marc Hedlund
<hedlund@best.com> on 11/26/95.
.PP
1.06 \fIfatalsToBrowser()\fR no longer aborts for fatal errors within
\fIeval()\fR statements.
.PP
1.08 \fIset_message()\fR added and \fIcarpout()\fR expanded to allow for FileHandle
objects.
.PP
1.09 \fIset_message()\fR now allows users to pass a code \s-1REFERENCE\s0 for
really custom error messages. croak and carp are now
exported by default. Thanks to Gunther Birznieks for the
patches.
.PP
1.10 Patch from Chris Dean (ctdean@cogit.com) to allow
module to run correctly under mod_perl.
.PP
1.11 Changed order of &gt; and &lt; escapes.
.PP
1.12 Changed \fIdie()\fR on line 217 to CORE::die to avoid \fB\-w\fR warning.
.PP
1.13 Added \fIcluck()\fR to make the module orthogonal with Carp.
More mod_perl related fixes.
.PP
1.20 Patch from Ilmari Karonen (perl@itz.pp.sci.fi): Added
\fIwarningsToBrowser()\fR. Replaced <\s-1CODE\s0> tags with <\s-1PRE\s0> in
\fIfatalsToBrowser()\fR output.
.PP
1.23 \fIineval()\fR now checks both $^S and inspects the message for the \*(L"eval\*(R" pattern
(hack alert!) in order to accomodate various combinations of Perl and
mod_perl.
.SH "AUTHORS"
.IX Header "AUTHORS"
Copyright 1995\-2002, Lincoln D. Stein. All rights reserved.
.PP
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
.PP
Address bug reports and comments to: lstein@cshl.org
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Carp, CGI::Base, CGI::BasePlus, CGI::Request, CGI::MiniSvr, CGI::Form,
CGI::Response