Edit D:\app\Administrator\product\11.2.0\dbhome_1\perl\html\lib\Carp.html
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>carp - warn of errors</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rev="made" href="mailto:" /> </head> <body style="background-color: white"> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> carp - warn of errors</span></strong></big> </td></tr> </table> <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> <ul> <li><a href="#name">NAME</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> <li><a href="#description">DESCRIPTION</a></li> <ul> <li><a href="#forcing_a_stack_trace">Forcing a Stack Trace</a></li> </ul> <li><a href="#global_variables">GLOBAL VARIABLES</a></li> <ul> <li><a href="#_carp__maxevallen">$Carp::MaxEvalLen</a></li> <li><a href="#_carp__maxarglen">$Carp::MaxArgLen</a></li> <li><a href="#_carp__maxargnums">$Carp::MaxArgNums</a></li> <li><a href="#_carp__verbose">$Carp::Verbose</a></li> <li><a href="#_carp__internal">%Carp::Internal</a></li> <li><a href="#_carp__carpinternal">%Carp::CarpInternal</a></li> <li><a href="#_carp__carplevel">$Carp::CarpLevel</a></li> </ul> <li><a href="#bugs">BUGS</a></li> </ul> <hr name="index" /> </div> <!-- INDEX END --> <p> </p> <h1><a name="name">NAME</a></h1> <p>carp - warn of errors (from perspective of caller)</p> <p>cluck - warn of errors with stack backtrace (not exported by default)</p> <p>croak - die of errors (from perspective of caller)</p> <p>confess - die of errors with stack backtrace</p> <p> </p> <hr /> <h1><a name="synopsis">SYNOPSIS</a></h1> <pre> use Carp; croak "We're outta here!";</pre> <pre> use Carp qw(cluck); cluck "This is how we got here!";</pre> <p> </p> <hr /> <h1><a name="description">DESCRIPTION</a></h1> <p>The Carp routines are useful in your own modules because they act like <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#die"><code>die()</code></a> or <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#warn"><code>warn()</code></a>, but with a message which is more likely to be useful to a user of your module. In the case of cluck, confess, and longmess that context is a summary of every call in the call-stack. For a shorter message you can use <code>carp</code> or <code>croak</code> which report the error as being from where your module was called. There is no guarantee that that is where the error was, but it is a good educated guess.</p> <p>You can also alter the way the output and logic of <code>Carp</code> works, by changing some global variables in the <code>Carp</code> namespace. See the section on <code>GLOBAL VARIABLES</code> below.</p> <p>Here is a more complete description of how c<carp> and c<croak> work. What they do is search the call-stack for a function call stack where they have not been told that there shouldn't be an error. If every call is marked safe, they give up and give a full stack backtrace instead. In other words they presume that the first likely looking potential suspect is guilty. Their rules for telling whether a call shouldn't generate errors work as follows:</p> <ol> <li> <p>Any call from a package to itself is safe.</p> </li> <li> <p>Packages claim that there won't be errors on calls to or from packages explicitly marked as safe by inclusion in <code>@CARP_NOT</code>, or (if that array is empty) <code>@ISA</code>. The ability to override what @ISA says is new in 5.8.</p> </li> <li> <p>The trust in item 2 is transitive. If A trusts B, and B trusts C, then A trusts C. So if you do not override <code>@ISA</code> with <code>@CARP_NOT</code>, then this trust relationship is identical to, "inherits from".</p> </li> <li> <p>Any call from an internal Perl module is safe. (Nothing keeps user modules from marking themselves as internal to Perl, but this practice is discouraged.)</p> </li> <li> <p>Any call to Perl's warning system (eg Carp itself) is safe. (This rule is what keeps it from reporting the error at the point where you call <code>carp</code> or <code>croak</code>.)</p> </li> <li> <p><code>$Carp::CarpLevel</code> can be set to skip a fixed number of additional call levels. Using this is not recommended because it is very difficult to get it to behave correctly.</p> </li> </ol> <p> </p> <h2><a name="forcing_a_stack_trace">Forcing a Stack Trace</a></h2> <p>As a debugging aid, you can force Carp to treat a croak as a confess and a carp as a cluck across <em>all</em> modules. In other words, force a detailed stack trace to be given. This can be very helpful when trying to understand why, or from where, a warning or error is being generated.</p> <p>This feature is enabled by 'importing' the non-existent symbol 'verbose'. You would typically enable it by saying</p> <pre> perl -MCarp=verbose script.pl</pre> <p>or by including the string <code>MCarp=verbose</code> in the PERL5OPT environment variable.</p> <p>Alternately, you can set the global variable <code>$Carp::Verbose</code> to true. See the <code>GLOBAL VARIABLES</code> section below.</p> <p> </p> <hr /> <h1><a name="global_variables">GLOBAL VARIABLES</a></h1> <p> </p> <h2><a name="_carp__maxevallen">$Carp::MaxEvalLen</a></h2> <p>This variable determines how many characters of a string-eval are to be shown in the output. Use a value of <code>0</code> to show all text.</p> <p>Defaults to <code>0</code>.</p> <p> </p> <h2><a name="_carp__maxarglen">$Carp::MaxArgLen</a></h2> <p>This variable determines how many characters of each argument to a function to print. Use a value of <code>0</code> to show the full length of the argument.</p> <p>Defaults to <code>64</code>.</p> <p> </p> <h2><a name="_carp__maxargnums">$Carp::MaxArgNums</a></h2> <p>This variable determines how many arguments to each function to show. Use a value of <code>0</code> to show all arguments to a function call.</p> <p>Defaults to <code>8</code>.</p> <p> </p> <h2><a name="_carp__verbose">$Carp::Verbose</a></h2> <p>This variable makes <code>carp</code> and <code>cluck</code> generate stack backtraces just like <code>cluck</code> and <code>confess</code>. This is how <code>use Carp 'verbose'</code> is implemented internally.</p> <p>Defaults to <code>0</code>.</p> <p> </p> <h2><a name="_carp__internal">%Carp::Internal</a></h2> <p>This says what packages are internal to Perl. <code>Carp</code> will never report an error as being from a line in a package that is internal to Perl. For example:</p> <pre> $Carp::Internal{ __PACKAGE__ }++; # time passes... sub foo { ... or confess("whatever") };</pre> <p>would give a full stack backtrace starting from the first caller outside of __PACKAGE__. (Unless that package was also internal to Perl.)</p> <p> </p> <h2><a name="_carp__carpinternal">%Carp::CarpInternal</a></h2> <p>This says which packages are internal to Perl's warning system. For generating a full stack backtrace this is the same as being internal to Perl, the stack backtrace will not start inside packages that are listed in <code>%Carp::CarpInternal</code>. But it is slightly different for the summary message generated by <code>carp</code> or <code>croak</code>. There errors will not be reported on any lines that are calling packages in <code>%Carp::CarpInternal</code>.</p> <p>For example <code>Carp</code> itself is listed in <code>%Carp::CarpInternal</code>. Therefore the full stack backtrace from <code>confess</code> will not start inside of <code>Carp</code>, and the short message from calling <code>croak</code> is not placed on the line where <code>croak</code> was called.</p> <p> </p> <h2><a name="_carp__carplevel">$Carp::CarpLevel</a></h2> <p>This variable determines how many additional call frames are to be skipped that would not otherwise be when reporting where an error occurred on a call to one of <code>Carp</code>'s functions. It is fairly easy to count these call frames on calls that generate a full stack backtrace. However it is much harder to do this accounting for calls that generate a short message. Usually people skip too many call frames. If they are lucky they skip enough that <code>Carp</code> goes all of the way through the call stack, realizes that something is wrong, and then generates a full stack backtrace. If they are unlucky then the error is reported from somewhere misleading very high in the call stack.</p> <p>Therefore it is best to avoid <code>$Carp::CarpLevel</code>. Instead use <code>@CARP_NOT</code>, <code>%Carp::Internal</code> and %Carp::CarpInternal>.</p> <p>Defaults to <code>0</code>.</p> <p> </p> <hr /> <h1><a name="bugs">BUGS</a></h1> <p>The Carp routines don't handle exception objects currently. If called with a first argument that is a reference, they simply call <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#die"><code>die()</code></a> or <a href="file://C|\ADE\aime_smenon_perl_090715\perl\html/pod/perlfunc.html#warn"><code>warn()</code></a>, as appropriate.</p> <table border="0" width="100%" cellspacing="0" cellpadding="3"> <tr><td class="block" style="background-color: #cccccc" valign="middle"> <big><strong><span class="block"> carp - warn of errors</span></strong></big> </td></tr> </table> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de