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

📄 ch02_04.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
字号:
<html><head><title>Perl's Built-in Warnings (Learning Perl, 3rd Edition)</title><link rel="stylesheet" type="text/css" href="../style/style1.css" /><meta name="DC.Creator" content="Randal L. Schwartz and Tom Phoenix" /><meta name="DC.Format" content="text/xml" scheme="MIME" /><meta name="DC.Language" content="en-US" /><meta name="DC.Publisher" content="O'Reilly &amp; Associates, Inc." /><meta name="DC.Source" scheme="ISBN" content="0596001320L" /><meta name="DC.Subject.Keyword" content="stuff" /><meta name="DC.Title" content="Learning Perl, 3rd Edition" /><meta name="DC.Type" content="Text.Monograph" /></head><body bgcolor="#ffffff"><img alt="Book Home" border="0" src="gifs/smbanner.gif" usemap="#banner-map" /><map name="banner-map"><area shape="rect" coords="1,-2,616,66" href="index.htm" alt="Learning Perl, 3rd Edition" /><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch02_03.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"></a></td><td align="right" valign="top" width="228"><a href="ch02_05.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr></table></div><h2 class="sect1">2.4. Perl's Built-in Warnings</h2><p>Perl can be told to warn you when it sees something suspicious goingon in your program. To run your program with<a name="INDEX-170" /><a name="INDEX-171" />warnings turned on, usethe <tt class="literal">-w</tt><a name="INDEX-172" /> option on the command line:</p><blockquote><pre class="code">$ <tt class="userinput"><b>perl -w </b></tt><em class="replaceable">my_program</em></pre></blockquote><p>Or, if you always want warnings, you may request them on the<tt class="literal">#!</tt> line:</p><blockquote><pre class="code">#!/usr/bin/perl -w</pre></blockquote><p>That works even on non-Unix systems, where it's traditional towrite something like this, since the path to Perl doesn'tgenerally matter:</p><blockquote><pre class="code">#!perl -w</pre></blockquote><p>Now, Perl will warn you if you use <tt class="literal">'12fred34'</tt> asif it were a number:</p><blockquote><pre class="code">Argument "12fred34" isn't numeric</pre></blockquote><p>Of course, warnings are generally meant for programmers, not forend-users. If the warning won't be seen by a programmer, itprobably won't do any good. And warnings won't change thebehavior of your program, except that now it will emit gripes once ina while. If you get a warning message you don't understand,look for its explanation in the<em class="emphasis">perldiag</em><a name="INDEX-173" /> manpage.</p><p>Warnings change from one version of Perl to the next. This may meanthat your well-tuned program runs silently when warnings are ontoday, but not when it's used with a newer (or older) versionof Perl. To help with this situation, version 5.6 of Perl introduces<em class="emphasis">lexical warnings</em><a name="INDEX-174" />. These are warnings that may be turnedon or off in different sections of code, providing more detailedcontrol than the single <tt class="literal">-w</tt> switch could. See the<em class="emphasis">perllexwarn</em><a name="INDEX-175" /> manpage for more information on thesewarnings.</p><p>As we run across situations in which Perl will usually be able towarn you about a mistake in your code, we'll point them out.But you shouldn't count on the text or behavior of any warningstaying exactly the same in future Perl releases.</p><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch02_03.htm"><img alt="Previous" border="0" src="../gifs/txtpreva.gif" /></a></td><td align="center" valign="top" width="228"><a href="index.htm"><img alt="Home" border="0" src="../gifs/txthome.gif" /></a></td><td align="right" valign="top" width="228"><a href="ch02_05.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">2.3. Strings</td><td align="center" valign="top" width="228"><a href="index/index.htm"><img alt="Book Index" border="0" src="../gifs/index.gif" /></a></td><td align="right" valign="top" width="228">2.5. Scalar Variables</td></tr></table></div><hr width="684" align="left" /><img alt="Library Navigation Links" border="0" src="../gifs/navbar.gif" usemap="#library-map" /><p><p><font size="-1"><a href="copyrght.htm">Copyright &copy; 2002</a> O'Reilly &amp; Associates. All rights reserved.</font></p><map name="library-map"><area shape="rect" coords="1,0,85,94" href="../index.htm"><area shape="rect" coords="86,1,178,103" href="../lwp/index.htm"><area shape="rect" coords="180,0,265,103" href="../lperl/index.htm"><area shape="rect" coords="267,0,353,105" href="../perlnut/index.htm"><area shape="rect" coords="354,1,446,115" href="../prog/index.htm"><area shape="rect" coords="448,0,526,132" href="../tk/index.htm"><area shape="rect" coords="528,1,615,119" href="../cookbook/index.htm"><area shape="rect" coords="617,0,690,135" href="../pxml/index.htm"></map></body></html>

⌨️ 快捷键说明

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