perldiag.html

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

HTML
1,387 行
字号
Usually it's a good idea to first collect the return values of the
created threads by joining them, and only then exit from the main
thread.  See <a href="../../lib/threads.html">the threads manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_access_disallowed_key__27_25s_27_in_a_r">Attempt to access disallowed key '%s' in a restricted hash</a></strong>

<dd>
<p>(F) The failing code has attempted to get or set a key which is not in
the current set of allowed keys of a restricted hash.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_bless_into_a_reference">Attempt to bless into a reference</a></strong>

<dd>
<p>(F) The CLASSNAME argument to the <a href="../../lib/Pod/perlfunc.html#item_bless"><code>bless()</code></a> operator is expected to be
the name of the package to bless the resulting object into. You've
supplied instead a reference to something: perhaps you wrote</p>
</dd>
<dd>
<pre>
    <span class="keyword">bless</span> <span class="variable">$self</span><span class="operator">,</span> <span class="variable">$proto</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<p>when you intended</p>
</dd>
<dd>
<pre>
    <span class="keyword">bless</span> <span class="variable">$self</span><span class="operator">,</span> <span class="keyword">ref</span><span class="operator">(</span><span class="variable">$proto</span><span class="operator">)</span> <span class="operator">||</span> <span class="variable">$proto</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<p>If you actually want to bless into the stringified version
of the reference supplied, you need to stringify it yourself, for
example by:</p>
</dd>
<dd>
<pre>
    <span class="keyword">bless</span> <span class="variable">$self</span><span class="operator">,</span> <span class="string">"$proto"</span><span class="operator">;</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_attempt_to_delete_disallowed_key__27_25s_27_from_a">Attempt to delete disallowed key '%s' from a restricted hash</a></strong>

<dd>
<p>(F) The failing code attempted to delete from a restricted hash a key
which is not in its key set.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_delete_readonly_key__27_25s_27_from_a_r">Attempt to delete readonly key '%s' from a restricted hash</a></strong>

<dd>
<p>(F) The failing code attempted to delete a key whose value has been
declared readonly from a restricted hash.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_free_non_2darena_sv_3a_0x_25lx">Attempt to free non-arena SV: 0x%lx</a></strong>

<dd>
<p>(P internal) All SV objects are supposed to be allocated from arenas
that will be garbage collected on exit.  An SV was discovered to be
outside any of those arenas.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_free_nonexistent_shared_string">Attempt to free nonexistent shared string</a></strong>

<dd>
<p>(P internal) Perl maintains a reference counted internal table of
strings to optimize the storage and access of hash keys and other
strings.  This indicates someone tried to decrement the reference count
of a string that can no longer be found in the table.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_free_temp_prematurely">Attempt to free temp prematurely</a></strong>

<dd>
<p>(W debugging) Mortalized values are supposed to be freed by the
<code>free_tmps()</code> routine.  This indicates that something else is freeing the
SV before the <code>free_tmps()</code> routine gets a chance, which means that the
<code>free_tmps()</code> routine will be freeing an unreferenced scalar when it does
try to free it.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_free_unreferenced_glob_pointers">Attempt to free unreferenced glob pointers</a></strong>

<dd>
<p>(P internal) The reference counts got screwed up on symbol aliases.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_free_unreferenced_scalar">Attempt to free unreferenced scalar</a></strong>

<dd>
<p>(W internal) Perl went to decrement the reference count of a scalar to
see if it would go to 0, and discovered that it had already gone to 0
earlier, and should have been freed, and in fact, probably was freed.
This could indicate that <code>SvREFCNT_dec()</code> was called too many times, or
that <code>SvREFCNT_inc()</code> was called too few times, or that the SV was
mortalized when it shouldn't have been, or that memory has been
corrupted.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_join_self">Attempt to join self</a></strong>

<dd>
<p>(F) You tried to join a thread from within itself, which is an
impossible task.  You may be joining the wrong thread, or you may need
to move the <a href="../../lib/Pod/perlfunc.html#item_join"><code>join()</code></a> to some other thread.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_pack_pointer_to_temporary_value">Attempt to pack pointer to temporary value</a></strong>

<dd>
<p>(W pack) You tried to pass a temporary value (like the result of a
function, or a computed expression) to the &quot;p&quot; <a href="../../lib/Pod/perlfunc.html#item_pack"><code>pack()</code></a> template.  This
means the result contains a pointer to a location that could become
invalid anytime, even before the end of the current statement.  Use
literals or global values as arguments to the &quot;p&quot; <a href="../../lib/Pod/perlfunc.html#item_pack"><code>pack()</code></a> template to
avoid this warning.</p>
</dd>
</li>
<dt><strong><a name="item_attempt_to_set_length_of_freed_array">Attempt to set length of freed array</a></strong>

<dd>
<p>(W) You tried to set the length of an array which has been freed.  You
can do this by storing a reference to the scalar representing the last index
of an array and later assigning through that reference. For example</p>
</dd>
<dd>
<pre>
    <span class="variable">$r</span> <span class="operator">=</span> <span class="keyword">do</span> <span class="operator">{</span><span class="keyword">my</span> <span class="variable">@a</span><span class="operator">;</span> <span class="operator">\</span><span class="variable">$#a</span><span class="operator">};</span>
    <span class="variable">$$r</span> <span class="operator">=</span> <span class="number">503</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_attempt_to_use_reference_as_lvalue_in_substr">Attempt to use reference as lvalue in substr</a></strong>

<dd>
<p>(W substr) You supplied a reference as the first argument to <a href="../../lib/Pod/perlvar.html#item_substr"><code>substr()</code></a>
used as an lvalue, which is pretty strange.  Perhaps you forgot to
dereference it first.  See <a href="../../lib/Pod/perlfunc.html#substr">substr in the perlfunc manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_bad_arg_length_for__25s_2c_is__25d_2c_should_be__2">Bad arg length for %s, is %d, should be %s</a></strong>

<dd>
<p>(F) You passed a buffer of the wrong size to one of msgctl(), <a href="../../lib/Pod/perlfunc.html#item_semctl"><code>semctl()</code></a>
or shmctl().  In C parlance, the correct sizes are, respectively,
sizeof(struct&nbsp;msqid_ds&nbsp;*), sizeof(struct&nbsp;semid_ds&nbsp;*), and
sizeof(struct&nbsp;shmid_ds&nbsp;*).</p>
</dd>
</li>
<dt><strong><a name="item_bad_evalled_substitution_pattern">Bad evalled substitution pattern</a></strong>

<dd>
<p>(F) You've used the <code>/e</code> switch to evaluate the replacement for a
substitution, but perl found a syntax error in the code to evaluate,
most likely an unexpected right brace '}'.</p>
</dd>
</li>
<dt><strong><a name="item_bad_filehandle_3a__25s">Bad filehandle: %s</a></strong>

<dd>
<p>(F) A symbol was passed to something wanting a filehandle, but the
symbol has no filehandle associated with it.  Perhaps you didn't do an
open(), or did it in another package.</p>
</dd>
</li>
<dt><strong><a name="item_free">Bad <code>free()</code> ignored</a></strong>

<dd>
<p>(S malloc) An internal routine called <a href="#item_free"><code>free()</code></a> on something that had never
been malloc()ed in the first place. Mandatory, but can be disabled by
setting environment variable <code>PERL_BADFREE</code> to 0.</p>
</dd>
<dd>
<p>This message can be seen quite often with DB_File on systems with &quot;hard&quot;
dynamic linking, like <code>AIX</code> and <a href="../../lib/Pod/perlrun.html#item_os_2f2"><code>OS/2</code></a>. It is a bug of <code>Berkeley DB</code>
which is left unnoticed if <code>DB</code> uses <em>forgiving</em> system malloc().</p>
</dd>
</li>
<dt><strong><a name="item_bad_hash">Bad hash</a></strong>

<dd>
<p>(P) One of the internal hash routines was passed a null HV pointer.</p>
</dd>
</li>
<dt><strong><a name="item_bad_index_while_coercing_array_into_hash">Bad index while coercing array into hash</a></strong>

<dd>
<p>(F) The index looked up in the hash found as the 0'th element of a
pseudo-hash is not legal.  Index values must be at 1 or greater.
See <a href="../../lib/Pod/perlref.html">the perlref manpage</a>.</p>
</dd>
</li>
<dt><strong><a name="item_placed">Badly placed ()'s</a></strong>

<dd>
<p>(A) You've accidentally run your script through <strong>csh</strong> instead
of Perl.  Check the #! line, or manually feed your script into
Perl yourself.</p>
</dd>
</li>
<dt><strong><a name="item_bad_name_after__25s_3a_3a">Bad name after %s::</a></strong>

<dd>
<p>(F) You started to name a symbol by using a package prefix, and then
didn't finish the symbol.  In particular, you can't interpolate outside
of quotes, so</p>
</dd>
<dd>
<pre>
    <span class="variable">$var</span> <span class="operator">=</span> <span class="string">'myvar'</span><span class="operator">;</span>
    <span class="variable">$sym</span> <span class="operator">=</span> <span class="variable">mypack:</span>:$<span class="variable">var</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<p>is not the same as</p>
</dd>
<dd>
<pre>
    <span class="variable">$var</span> <span class="operator">=</span> <span class="string">'myvar'</span><span class="operator">;</span>
    <span class="variable">$sym</span> <span class="operator">=</span> <span class="string">"mypack::$var"</span><span class="operator">;</span>
</pre>
</dd>
</li>
<dt><strong><a name="item_realloc">Bad <code>realloc()</code> ignored</a></strong>

<dd>
<p>(S malloc) An internal routine called <a href="#item_realloc"><code>realloc()</code></a> on something that had
never been malloc()ed in the first place. Mandatory, but can be disabled
by setting environment variable <code>PERL_BADFREE</code> to 1.</p>
</dd>
</li>
<dt><strong><a name="item_bad_symbol_for_array">Bad symbol for array</a></strong>

<dd>
<p>(P) An internal request asked to add an array entry to something that
wasn't a symbol table entry.</p>
</dd>
</li>
<dt><strong><a name="item_bad_symbol_for_filehandle">Bad symbol for filehandle</a></strong>

<dd>
<p>(P) An internal request asked to add a filehandle entry to something
that wasn't a symbol table entry.</p>
</dd>
</li>
<dt><strong><a name="item_bad_symbol_for_hash">Bad symbol for hash</a></strong>

<dd>
<p>(P) An internal request asked to add a hash entry to something that
wasn't a symbol table entry.</p>
</dd>
</li>
<dt><strong><a name="item_bareword_found_in_conditional">Bareword found in conditional</a></strong>

<dd>
<p>(W bareword) The compiler found a bareword where it expected a
conditional, which often indicates that an || or &amp;&amp; was parsed as part
of the last argument of the previous construct, for example:</p>
</dd>
<dd>
<pre>
    <span class="keyword">open</span> <span class="variable">FOO</span> <span class="operator">||</span> <span class="keyword">die</span><span class="operator">;</span>
</pre>
</dd>
<dd>
<p>It may also indicate a misspelled constant that has been interpreted as
a bareword:</p>
</dd>
<dd>
<pre>
    <span class="keyword">use</span> <span class="variable">constant</span> <span class="string">TYPO</span> <span class="operator">=&gt;</span> <span class="number">1</span><span class="operator">;</span>
    <span class="keyword">if</span> <span class="operator">(</span><span class="variable">TYOP</span><span class="operator">)</span> <span class="operator">{</span> <span class="keyword">print</span> <span class="string">"foo"</span> <span class="operator">}</span>
</pre>
</dd>
<dd>

⌨️ 快捷键说明

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