⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch33_01.htm

📁 编程珍珠,里面很多好用的代码,大家可以参考学习呵呵,
💻 HTM
📖 第 1 页 / 共 5 页
字号:
<html><head><title>Diagnostic Messages (Programming Perl)</title><!-- STYLESHEET --><link rel="stylesheet" type="text/css" href="../style/style1.css"><!-- METADATA --><!--Dublin Core Metadata--><meta name="DC.Creator" content=""><meta name="DC.Date" content=""><meta name="DC.Format" content="text/xml" scheme="MIME"><meta name="DC.Generator" content="XSLT stylesheet, xt by James Clark"><meta name="DC.Identifier" content=""><meta name="DC.Language" content="en-US"><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc."><meta name="DC.Source" content="" scheme="ISBN"><meta name="DC.Subject.Keyword" content=""><meta name="DC.Title" content="Diagnostic Messages"><meta name="DC.Type" content="Text.Monograph"></head><body><!-- START OF BODY --><!-- TOP BANNER --><img src="gifs/smbanner.gif" usemap="#banner-map" border="0" alt="Book Home"><map name="banner-map"><AREA SHAPE="RECT" COORDS="0,0,466,71" HREF="index.htm" ALT="Programming Perl"><AREA SHAPE="RECT" COORDS="467,0,514,18" HREF="jobjects/fsearch.htm" ALT="Search this book"></map><!-- TOP NAV BAR --><div class="navbar"><table width="515" border="0"><tr><td align="left" valign="top" width="172"><a href="ch32_47.htm"><img src="../gifs/txtpreva.gif" alt="Previous" border="0"></a></td><td align="center" valign="top" width="171"><a href="part5.htm">Part 5: Reference Material</a></td><td align="right" valign="top" width="172"></td></tr></table></div><hr width="515" align="left"><!-- SECTION BODY --><h1 class="chapter">Chapter 33.  Diagnostic Messages</h1><p><a name="INDEX-5822"></a><a name="INDEX-5823"></a><a name="INDEX-5824"></a><a name="INDEX-5825"></a>These messages are classified as follows (listed in increasing order ofdesperation):</p><a name="perl2-ch-9-tab-1"></a><table border="1"><tr><th>Class</th><th>Meaning</th></tr><tr><td>(W)</td><td>A warning (optional)</td></tr><tr><td>(D)</td><td>A deprecation (optional)</td></tr><tr><td>(S)</td><td>A severe warning (mandatory)</td></tr><tr><td>(F)</td><td>A fatal error (trappable)</td></tr><tr><td>(P)</td><td>An internal error (panic) that you should never see (trappable)</td></tr><tr><td>(X)</td><td>A very fatal error (nontrappable)</td></tr><tr><td>(A)</td><td>An alien error message (not generated by Perl)</td></tr></table><p><a name="INDEX-5826"></a><a name="INDEX-5827"></a><a name="INDEX-5828"></a>The majority of messages from the first three classifications above(W, D, and S) can be controlled using the <tt class="literal">warnings</tt> pragma or the <span class="option">-w</span>and <span class="option">-W</span> switches.  If a message can be controlled by the <tt class="literal">warnings</tt>pragma, its warning category is given after the classificationletter; for example, (W misc) indicates a miscellaneous warning. The <tt class="literal">warnings</tt> pragma is describedin <a href="ch31_01.htm">Chapter 31, "Pragmatic Modules"</a>.</p><p>Warnings may be captured rather than printed by setting <tt class="literal">$SIG{__WARN__}</tt> to a referenceto a routine that will be called on each warning.  You can also capture control before a trappable error "dies" bysetting <tt class="literal">$SIG{__DIE__}</tt> to a subroutine reference, but if you don'tcall <tt class="literal">die</tt> within the handler, the exception is still thrownwhen you return from it.  In other words, you're not allowed to"de-fatalize" an exception that way.  You must use <tt class="literal">eval</tt> for that.</p><p>Default warnings are always enabled unless they are explicitly disabledwith the <tt class="literal">warnings</tt> pragma or the <span class="option">-X</span> switch.</p><p>In the following messages, <em class="replaceable">%s</em> stands for an interpolated string thatis determined only when the message is generated.  (Similarly, <em class="replaceable">%d</em>stands for an interpolated number--think <tt class="literal">printf</tt> formats, but we use<em class="replaceable">%d</em> to mean a number in any base here.)  Note that some messages<em class="emphasis">begin</em> with <em class="replaceable">%s</em>--which means that listing them alphabetically isproblematical.  You should search among these messages if the one youare looking for does not appear in the expected place.  The symbols<tt class="literal">"%-?@</tt> sort before alphabetic characters, while <tt class="literal">[</tt> and <tt class="literal">\</tt> sortafter.</p><p><a name="INDEX-5829"></a>If you decide a bug is a Perl bug and not your bug, you should try toreduce it to a minimal test case and then report it with the <em class="emphasis">perlbug</em>program that comes with Perl.</p><dl><dt><b><tt class="literal">"</tt><em class="replaceable">%s</em><tt class="literal">" variable</tt> <em class="replaceable">%s</em> <tt class="literal">masks earlier declaration in same</tt> <em class="replaceable">%s</em></b></dt><dd><p>(W misc) A <tt class="literal">my</tt> or <tt class="literal">our</tt> variable has been redeclared in the currentscope or statement, effectively eliminating all access to the previousinstance.  This is almost always a typographical error.  Note that theearlier variable will still exist until the end of the scope or untilall closure referents to it are destroyed.</p></dd><dt><b><tt class="literal">"my sub" not yet implemented</tt></b></dt><dd><p>(F) Lexically scoped subroutines are not yet implemented.  Don't try thatyet.</p></dd><dt><b><tt class="literal">"my" variable</tt> <em class="replaceable">%s</em> <tt class="literal">can't be in a package</tt></b></dt><dd><p>(F) Lexically scoped variables aren't in a package, so it doesn't make senseto try to declare one with a package qualifier in front.  Use <tt class="literal">local</tt>if you want to localize a package variable.</p></dd><dt><b><tt class="literal">"no" not allowed in expression</tt></b></dt><dd><p>(F) The <tt class="literal">no</tt> keyword is recognized and executed at compile time and returnsno useful value.</p></dd><dt><b><tt class="literal">"our" variable</tt> <em class="replaceable">%s</em> <tt class="literal">redeclared</tt></b></dt><dd><p>(W misc) You seem to have already declared the same global once before in thecurrent lexical scope.</p></dd><dt><b><tt class="literal">"use" not allowed in expression</tt></b></dt><dd><p>(F) The <tt class="literal">use</tt> keyword is recognized and executed at compile time andreturns no useful value.</p></dd><dt><b><tt class="literal">'!' allowed only after types</tt> <em class="replaceable">%s</em> </b></dt><dd><p>(F) The <tt class="literal">'!'</tt> is allowed in <tt class="literal">pack</tt> and <tt class="literal">unpack</tt> only after certain types.</p></dd><dt><b><tt class="literal">'|' and '&lt;' may not both be specified on command line</tt></b></dt><dd><p>(F) This is an error peculiar to VMS.  Perl does its own command-lineredirection. It found that <tt class="literal">STDIN</tt> was a pipe and that you also triedto redirect <tt class="literal">STDIN</tt> using <tt class="literal">&lt;</tt>.  Only one <tt class="literal">STDIN</tt> stream to a customer,please.</p></dd><dt><b><tt class="literal">'|' and '&gt;' may not both be specified on command line</tt></b></dt><dd><p>(F) This is an error peculiar to VMS.  Perl does its own command-line redirection andthinks you tried to redirect <tt class="literal">STDOUT</tt> both to a file and into a pipe to anothercommand.  You need to choose one or the other, though nothing's stopping youfrom piping into a program or Perl script that splits the output into twostreams, such as:<blockquote><pre class="programlisting">open(OUT,"&gt;$ARGV[0]") or die "Can't write to $ARGV[0]: $!";while (&lt;STDIN&gt;) {    print;    print OUT;}close OUT;</pre></blockquote></p></dd><dt><b><tt class="literal">/ cannot take a count</tt></b></dt><dd><p>(F) You had an <tt class="literal">unpack</tt> template indicating a counted-length string,but you have also specified an explicit size for the string.</p></dd><dt><b><tt class="literal">/ must be followed by a, A, or Z</tt></b></dt><dd><p>(F) You had an <tt class="literal">unpack</tt> template indicating a counted-length string,which must be followed by one of the letters <tt class="literal">a</tt>, <tt class="literal">A</tt> or <tt class="literal">Z</tt>to indicate what sort of string is to be unpacked.</p></dd><dt><b><tt class="literal">/ must be followed by a*, A*, or Z*</tt></b></dt><dd><p>(F) You had a pack template indicating a counted-length string.Currently, the only things that can have their length counted are <tt class="literal">a*</tt>,<tt class="literal">A*</tt> or <tt class="literal">Z*</tt>.</p></dd><dt><b><tt class="literal">/ must follow a numeric type</tt></b></dt><dd><p>(F) You had an <tt class="literal">unpack</tt> template that contained a <tt class="literal">#</tt>,but this did not follow some numeric <tt class="literal">unpack</tt> specification.</p></dd><dt><b><tt class="literal">% may only be used in unpack</tt></b></dt><dd><p>(F) You can't <tt class="literal">pack</tt> a string by supplying a checksum, because thechecksumming process loses information, and you can't go the otherway.</p></dd><dt><b><tt class="literal">Repeat count in pack overflows</tt></b></dt><dd><p>(F) You can't specify a repeat count so large that it overflows yoursigned integers.</p></dd><dt><b><tt class="literal">Repeat count in unpack overflows</tt></b></dt><dd><p>(F) You can't specify a repeat count so large that it overflowsyour signed integers.</p></dd><dt><b><tt class="literal">/</tt><em class="replaceable">%s</em><tt class="literal">/: Unrecognized escape \\<em class="replaceable">%c</em> passed through</tt></b></dt><dd><p>(W regexp) You used a backslash-character combination that is notrecognized by Perl.  This combination appears in an interpolatedvariable or a <tt class="literal">'</tt>-delimited regular expression.  The character wasunderstood literally.</p></dd><dt><b><tt class="literal">/</tt><em class="replaceable">%s</em><tt class="literal">/: Unrecognized escape \\<em class="replaceable">%c</em> in character class passed through</tt></b></dt><dd><p>(W regexp) You used a backslash-character combination that is notrecognized by Perl inside character classes.  The character wasunderstood literally.</p></dd><dt><b><tt class="literal">/</tt><em class="replaceable">%s</em><tt class="literal">/ should probably be written as "</tt><em class="replaceable">%s</em><tt class="literal">"</tt></b></dt><dd><p>(W syntax) You have used a pattern where Perl expected to find a string,as in the first argument to <tt class="literal">join</tt>.  Perl will treat the trueor false result of matching the pattern against <tt class="literal">$_</tt> as the string,which is probably not what you had in mind.</p></dd><dt><b><em class="replaceable">%s</em> <tt class="literal">(...) interpreted as function</tt></b></dt><dd><p>(W syntax) You've run afoul of the rule that says that any listoperator followed by parentheses turns into a function, with all thelist operators arguments found inside the parentheses.</p></dd><dt><b><em class="replaceable">%s</em><tt class="literal">() called too early to check prototype</tt></b></dt><dd><p>(W prototype) You've called a function that has a prototype before theparser saw a definition or declaration for it, and Perl could notcheck that the call conforms to the prototype.  You need to either addan early prototype declaration for the subroutine in question, or movethe subroutine definition ahead of the call to get proper prototypechecking.  Alternatively, if you are certain that you're calling thefunction correctly, you may put an ampersand before the name to avoidthe warning.</p></dd><dt><b><em class="replaceable">%s</em> <tt class="literal">argument is not a HASH or ARRAY element</tt></b></dt><dd><p>(F) The argument to <tt class="literal">exists</tt> must be a hash or array element, such as:<blockquote><pre class="programlisting">$foo{$bar}$ref-&gt;{"susie"}[12]</pre></blockquote></p></dd><dt><b><em class="replaceable">%s</em> <tt class="literal">argument is not a HASH or ARRAY element or slice</tt></b></dt><dd><p>(F) The argument to <tt class="literal">delete</tt> must be either a hash or array element, such as:<blockquote><pre class="programlisting">$foo{$bar}$ref-&gt;{"susie"}[12]</pre></blockquote>

⌨️ 快捷键说明

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