perldiag.html

来自「perl教程」· HTML 代码 · 共 1,387 行 · 第 1/5 页

HTML
1,387
字号
<?xml version="1.0" ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<!-- saved from url=(0017)http://localhost/ -->
<script language="JavaScript" src="../../displayToc.js"></script>
<script language="JavaScript" src="../../tocParas.js"></script>
<script language="JavaScript" src="../../tocTab.js"></script>
<link rel="stylesheet" type="text/css" href="../../scineplex.css">
<title>perldiag - various Perl diagnostics</title>
<link rel="stylesheet" href="../../Active.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:" />
</head>

<body>

<script>writelinks('__top__',2);</script>
<h1><a>perldiag - various Perl diagnostics</a></h1>
<p><a name="__index__"></a></p>

<!-- INDEX BEGIN -->

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>perldiag - various Perl diagnostics</p>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>These messages are classified as follows (listed in increasing order of
desperation):</p>
<pre>
    (W) A warning (optional).
    (D) A deprecation (optional).
    (S) A severe warning (default).
    (F) A fatal error (trappable).
    (P) An internal error you should never see (trappable).
    (X) A very fatal error (nontrappable).
    (A) An alien error message (not generated by Perl).</pre>
<p>The majority of messages from the first three classifications above
(W, D &amp; S) can be controlled using the <code>warnings</code> pragma.</p>
<p>If a message can be controlled by the <code>warnings</code> pragma, its warning
category is included with the classification letter in the description
below.</p>
<p>Optional warnings are enabled by using the <code>warnings</code> pragma or the <strong>-w</strong>
and <strong>-W</strong> switches. Warnings may be captured by setting <code>$SIG{__WARN__}</code>
to a reference to a routine that will be called on each warning instead
of printing it.  See <a href="../../lib/Pod/perlvar.html">the perlvar manpage</a>.</p>
<p>Default warnings are always enabled unless they are explicitly disabled
with the <code>warnings</code> pragma or the <strong>-X</strong> switch.</p>
<p>Trappable errors may be trapped using the eval operator.  See
<a href="../../lib/Pod/perlfunc.html#eval">eval in the perlfunc manpage</a>.  In almost all cases, warnings may be selectively
disabled or promoted to fatal errors using the <code>warnings</code> pragma.
See <a href="../../lib/warnings.html">the warnings manpage</a>.</p>
<p>The messages are in alphabetical order, without regard to upper or
lower-case.  Some of these messages are generic.  Spots that vary are
denoted with a %s or other printf-style escape.  These escapes are
ignored by the alphabetical order, as are all characters other than
letters.  To look up your message, just ignore anything that is not a
letter.</p>
<dl>
<dt><strong><a name="item_accept"><code>accept()</code> on closed socket %s</a></strong>

<dd>
<p>(W closed) You tried to do an accept on a closed socket.  Did you forget
to check the return value of your <a href="../../lib/Pod/perlfunc.html#item_socket"><code>socket()</code></a> call?  See
<a href="../../lib/Pod/perlfunc.html#accept">accept in the perlfunc manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_allocation_too_large_3a__25lx">Allocation too large: %lx</a></strong>

<dd>
<p>(X) You can't allocate more than 64K on an MS-DOS machine.</p>
</dd>
</li>
<dt><strong><a name="item__27_21_27_allowed_only_after_types__25s">'!' allowed only after types %s</a></strong>

<dd>
<p>(F) The '!' is allowed in <a href="../../lib/Pod/perlfunc.html#item_pack"><code>pack()</code></a> or <a href="../../lib/Pod/perlfunc.html#item_unpack"><code>unpack()</code></a> only after certain types.
See <a href="../../lib/Pod/perlfunc.html#pack">pack in the perlfunc manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_s">Ambiguous call resolved as CORE::%s(), qualify as such or use &amp;</a></strong>

<dd>
<p>(W ambiguous) A subroutine you have declared has the same name as a Perl
keyword, and you have used the name without qualification for calling
one or the other.  Perl decided to call the builtin because the
subroutine is not imported.</p>
</dd>
<dd>
<p>To force interpretation as a subroutine call, either put an ampersand
before the subroutine name, or qualify the name with its package.
Alternatively, you can import the subroutine (or pretend that it's
imported with the <code>use subs</code> pragma).</p>
</dd>
<dd>
<p>To silently interpret it as the Perl operator, use the <code>CORE::</code> prefix
on the operator (e.g. <a href="../../lib/Pod/perlfunc.html#item_log"><code>CORE::log($x)</code></a>) or declare the subroutine
to be an object method (see <a href="../../lib/Pod/perlsub.html#subroutine_attributes">Subroutine Attributes in the perlsub manpage</a> or
<a href="../../lib/attributes.html">the attributes manpage</a>).</p>
</dd>
</li>
<dt><strong><a name="item_ambiguous_range_in_transliteration_operator">Ambiguous range in transliteration operator</a></strong>

<dd>
<p>(F) You wrote something like <a href="../../lib/Pod/perlfunc.html#item_tr_"><code>tr/a-z-0//</code></a> which doesn't mean anything at
all.  To include a <code>-</code> character in a transliteration, put it either
first or last.  (In the past, <a href="../../lib/Pod/perlfunc.html#item_tr_"><code>tr/a-z-0//</code></a> was synonymous with
<a href="../../lib/Pod/perlfunc.html#item_tr_"><code>tr/a-y//</code></a>, which was probably not what you would have expected.)</p>
</dd>
</li>
<dt><strong><a name="item_ambiguous_use_of__25s_resolved_as__25s">Ambiguous use of %s resolved as %s</a></strong>

<dd>
<p>(W ambiguous)(S) You said something that may not be interpreted the way
you thought.  Normally it's pretty easy to disambiguate it by supplying
a missing quote, operator, parenthesis pair or declaration.</p>
</dd>
</li>
<dt><strong><a name="item__27_7c_27_and__27_3c_27_may_not_both_be_specified_">'|' and '&lt;' may not both be specified on command line</a></strong>

<dd>
<p>(F) An error peculiar to VMS.  Perl does its own command line
redirection, and found that STDIN was a pipe, and that you also tried to
redirect STDIN using '&lt;'.  Only one STDIN stream to a customer, please.</p>
</dd>
</li>
<dt><strong><a name="item__27_7c_27_and__27_3e_27_may_not_both_be_specified_">'|' and '&gt;' may not both be specified on command line</a></strong>

<dd>
<p>(F) An error peculiar to VMS.  Perl does its own command line
redirection, and thinks you tried to redirect stdout both to a file and
into a pipe to another command.  You need to choose one or the other,
though nothing's stopping you from piping into a program or Perl script
which 'splits' output into two streams, such as</p>
</dd>
<dd>
<pre>
    <span class="keyword">open</span><span class="operator">(</span><span class="variable">OUT</span><span class="operator">,</span><span class="string">"&gt;$ARGV[0]"</span><span class="operator">)</span> <span class="keyword">or</span> <span class="keyword">die</span> <span class="string">"Can't write to $ARGV[0]: $!"</span><span class="operator">;</span>
    <span class="keyword">while</span> <span class="operator">(&lt;</span><span class="variable">STDIN</span><span class="operator">&gt;)</span> <span class="operator">{</span>
        <span class="keyword">print</span><span class="operator">;</span>
        <span class="keyword">print</span> <span class="variable">OUT</span><span class="operator">;</span>
    <span class="operator">}</span>
    <span class="keyword">close</span> <span class="variable">OUT</span><span class="operator">;</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_scalar">Applying %s to %s will act on <code>scalar(%s)</code></a></strong>

<dd>
<p>(W misc) The pattern match (<code>//</code>), substitution (<a href="../../lib/Pod/perlfunc.html#item_s_"><code>s///</code></a>), and
transliteration (<a href="../../lib/Pod/perlfunc.html#item_tr_"><code>tr///</code></a>) operators work on scalar values.  If you apply
one of them to an array or a hash, it will convert the array or hash to
a scalar value -- the length of an array, or the population info of a
hash -- and then work on that scalar value.  This is probably not what
you meant to do.  See <a href="../../lib/Pod/perlfunc.html#grep">grep in the perlfunc manpage</a> and <a href="../../lib/Pod/perlfunc.html#map">map in the perlfunc manpage</a> for
alternatives.</p>
</dd>
</li>
<dt><strong><a name="item_args_must_match__23_21_line">Args must match #! line</a></strong>

<dd>
<p>(F) The setuid emulator requires that the arguments Perl was invoked
with match the arguments specified on the #! line.  Since some systems
impose a one-argument limit on the #! line, try combining switches;
for example, turn <code>-w -U</code> into <code>-wU</code>.</p>
</dd>
</li>
<dt><strong><a name="item_arg_too_short_for_msgsnd">Arg too short for msgsnd</a></strong>

<dd>
<p>(F) <a href="../../lib/Pod/perlfunc.html#item_msgsnd"><code>msgsnd()</code></a> requires a string at least as long as sizeof(long).</p>
</dd>
</li>
<dt><strong><a name="item__s">%s argument is not a HASH or ARRAY element</a></strong>

<dd>
<p>(F) The argument to <a href="../../lib/Pod/perlfunc.html#item_exists"><code>exists()</code></a> must be a hash or array element, such as:</p>
</dd>
<dd>
<pre>
    <span class="variable">$foo</span><span class="operator">{</span><span class="variable">$bar</span><span class="operator">}</span>
    <span class="variable">$ref</span><span class="operator">-&gt;</span><span class="operator">{</span><span class="string">"susie"</span><span class="operator">}[</span><span class="number">12</span><span class="operator">]</span>
</pre>
</dd>
</li>
<dt><strong>%s argument is not a HASH or ARRAY element or slice</strong>

<dd>
<p>(F) The argument to <a href="../../lib/Pod/perlfunc.html#item_delete"><code>delete()</code></a> must be either a hash or array element,
such as:</p>
</dd>
<dd>
<pre>
    <span class="variable">$foo</span><span class="operator">{</span><span class="variable">$bar</span><span class="operator">}</span>
    <span class="variable">$ref</span><span class="operator">-&gt;</span><span class="operator">{</span><span class="string">"susie"</span><span class="operator">}[</span><span class="number">12</span><span class="operator">]</span>
</pre>
</dd>
<dd>
<p>or a hash or array slice, such as:</p>
</dd>
<dd>
<pre>
    <span class="variable">@foo</span><span class="operator">[</span><span class="variable">$bar</span><span class="operator">,</span> <span class="variable">$baz</span><span class="operator">,</span> <span class="variable">$xyzzy</span><span class="operator">]</span>
    <span class="variable">@</span><span class="operator">{</span><span class="variable">$ref</span><span class="operator">-&gt;</span><span class="operator">[</span><span class="number">12</span><span class="operator">]}{</span><span class="string">"susie"</span><span class="operator">,</span> <span class="string">"queue"</span><span class="operator">}</span>
</pre>
</dd>
</li>
<dt><strong>%s argument is not a subroutine name</strong>

<dd>
<p>(F) The argument to <a href="../../lib/Pod/perlfunc.html#item_exists"><code>exists()</code></a> for <code>exists &amp;sub</code> must be a subroutine
name, and not a subroutine call.  <a href="../../lib/Pod/perlfunc.html#item_sub"><code>exists &amp;sub()</code></a> will generate this
error.</p>
</dd>
</li>
<dt><strong><a name="item_argument__22_25s_22_isn_27t_numeric_25s">Argument &quot;%s&quot; isn't numeric%s</a></strong>

<dd>
<p>(W numeric) The indicated string was fed as an argument to an operator
that expected a numeric value instead.  If you're fortunate the message
will identify which operator was so unfortunate.</p>
</dd>
</li>
<dt><strong><a name="item_argument_list_not_closed_for_perlio_layer__22_25s_">Argument list not closed for PerlIO layer &quot;%s&quot;</a></strong>

<dd>
<p>(W layer) When pushing a layer with arguments onto the Perl I/O system you
forgot the ) that closes the argument list.  (Layers take care of transforming
data between external and internal representations.)  Perl stopped parsing
the layer list at this point and did not attempt to push this layer.
If your program didn't explicitly request the failing operation, it may be
the result of the value of the environment variable PERLIO.</p>
</dd>
</li>
<dt><strong>Array @%s missing the @ in argument %d of %s()</strong>

<dd>
<p>(D deprecated) Really old Perl let you omit the @ on array names in some
spots.  This is now heavily deprecated.</p>
</dd>
</li>
<dt><strong><a name="item_assertion_botched_3a__25s">assertion botched: %s</a></strong>

<dd>
<p>(P) The malloc package that comes with Perl had an internal failure.</p>
</dd>
</li>
<dt><strong><a name="item_assertion_failed_3a_file__22_25s_22">Assertion failed: file &quot;%s&quot;</a></strong>

<dd>
<p>(P) A general assertion failed.  The file in question must be examined.</p>
</dd>
</li>
<dt><strong><a name="item_assignment_to_both_a_list_and_a_scalar">Assignment to both a list and a scalar</a></strong>

<dd>
<p>(F) If you assign to a conditional operator, the 2nd and 3rd arguments
must either both be scalars or both be lists.  Otherwise Perl won't
know which context to supply to the right side.</p>
</dd>
</li>
<dt><strong><a name="item_a_thread_exited_while__25d_threads_were_running">A thread exited while %d threads were running</a></strong>

<dd>
<p>(W threads)(S) When using threaded Perl, a thread (not necessarily the main
thread) exited while there were still other threads running.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?