📄 prf2_04.htm
字号:
<HTML><HEAD><METANAME="DC.title"CONTENT="Perl Cookbook"><METANAME="DC.creator"CONTENT="Tom Christiansen & Nathan Torkington"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1999-07-02T01:28:14Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-243-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="prf2_01.htm"TITLE="Preface"><LINKREL="prev"HREF="prf2_03.htm"TITLE="Other Books"><LINKREL="next"HREF="prf2_05.htm"TITLE="We'd Like to Hear from You"></HEAD><BODYBGCOLOR="#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="Perl Cookbook"><area shape="rect" coords="629,-11,726,25" href="jobjects/fsearch.htm" alt="Search this book" /></map><div class="navbar"><p><TABLEWIDTH="684"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="228"><ACLASS="sect1"HREF="prf2_03.htm"TITLE="Other Books"><IMGSRC="../gifs/txtpreva.gif"ALT="Previous: Other Books"BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="228"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1"><ACLASS="preface"REL="up"HREF="prf2_01.htm"TITLE="Preface">Preface</A></FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="228"><ACLASS="sect1"HREF="prf2_05.htm"TITLE="We'd Like to Hear from You"><IMGSRC="../gifs/txtnexta.gif"ALT="Next: We'd Like to Hear from You"BORDER="0"></A></TD></TR></TABLE></DIV><DIVCLASS="sect1"><H2CLASS="sect1"><ACLASS="title"NAME="ch00-chap00_conventions_0">Conventions Used in This Book</A></H2><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="ch00-chap00_programming_0">Programming Conventions</A></H3><PCLASS="para"><ACLASS="indexterm"NAME="ch00-idx-1000003236-0"></A><ACLASS="indexterm"NAME="ch00-idx-1000003236-1"></A>We are firm believers in using Perl's<ICLASS="function"> </I><BCLASS="emphasis.bold">-w</B> command-line option and its <CODECLASS="literal">use strict</CODE> pragma in every non-trivial program. We start nearly all our longer programs with:</P><PRECLASS="programlisting">#!/usr/bin/perl -wuse strict;</PRE><PCLASS="para">We give lots of examples, most of which are pieces of code that should go into a larger program. Some examples are complete programs, which you can recognize because they begin with a <CODECLASS="literal">#!</CODE> line.</P><PCLASS="para">Still other examples are things to be typed on a command line. We've used <CODECLASS="literal">%</CODE> to indicate the shell prompt:</P><PRECLASS="programlisting">% perl -e 'print "Hello, world.\n"'<CODECLASS="userinput"><B><CODECLASS="replaceable"><I>Hello, world.</I></CODE></B></CODE></PRE><PCLASS="para">This style is representative of a standard Unix command line. Quoting and wildcard conventions on other systems vary. For example, most standard command-line interpreters under DOS and VMS require double quotes instead of single ones to group arguments with spaces or wildcards in them. Adjust accordingly.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="ch00-pgfId-1000002555">Typesetting Conventions</A></H3><PCLASS="para">The following typographic conventions are used in this book:</P><DLCLASS="variablelist"><DTCLASS="term"><EMCLASS="emphasis">Italic</EM></DT><DDCLASS="listitem"><PCLASS="para">is used for filenames, command names, and URLs. It is also used to define new terms when they first appear in the text.</P></DD><DTCLASS="term"><BCLASS="emphasis.bold">Bold</B></DT><DDCLASS="listitem"><PCLASS="para">is used for command-line options.</P></DD><DTCLASS="term"><CODECLASS="literal">Constant Width</CODE> </DT><DDCLASS="listitem"><PCLASS="para">is used for function and method names and their arguments; in examples to show the text that you enter literally; and in regular text to show any literal code.</P></DD><DTCLASS="term"><CODECLASS="userinput"><B><CODECLASS="replaceable"><I>Constant Bold Italic</I></CODE></B></CODE></DT><DDCLASS="listitem"><PCLASS="para">is used in examples to show output produced.</P></DD></DL></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="ch00-pgfId-1000002562">Documentation Conventions</A></H3><PCLASS="para"><ACLASS="indexterm"NAME="ch00-idx-1000003237-0"></A><ACLASS="indexterm"NAME="ch00-idx-1000003237-1"></A>The most up-to-date and complete documentation about Perl is included with Perl itself. If typeset and printed, this massive anthology would use more than a thousand pages of printer pager, greatly contributing to global deforestation. Fortunately, you don't have to print it out because it's available in a convenient and searchable electronic form.</P><PCLASS="para">When we refer to a "manpage" in this book, we're talking about this set of online manuals. The name is purely a convention; you don't need a Unix-style <KBDCLASS="command">man</KBD> program to read them. The <EMCLASS="emphasis">perldoc</EM> command distributed with Perl also works, and you may even have the manpages installed as HTML pages, especially on non-Unix systems. Plus, once you know where they're installed, you can <KBDCLASS="command">grep</KBD> them directly.[<ACLASS="footnote"HREF="#ch00-pgfId-1000002608">1</A>]The HTML version of the manpages is available on the Web at <ACLASS="systemitem.url"HREF="http://www.perl.com/CPAN/doc/manual/html/">http://www.perl.com/CPAN/doc/manual/html/</A>.</P><BLOCKQUOTECLASS="footnote"><DIVCLASS="footnote"><PCLASS="para"><ACLASS="footnote"NAME="ch00-pgfId-1000002608">[1]</A> If your system doesn't have <ICLASS="filename">grep</I>, use the <ICLASS="filename">tcgrep</I> program supplied at the end of <ACLASS="xref"HREF="ch06_01.htm"TITLE="Pattern Matching">Chapter 6</A>.</P></DIV></BLOCKQUOTE><PCLASS="para">When we refer to non-Perl documentation, as in "See <ICLASS="filename">kill </I>(2) in your system manual," this refers to the <ICLASS="filename">kill</I> manpage from section 2 of the <CITECLASS="citetitle">Unix Programmer's Manual</CITE> (system calls). These won't be available on non-Unix systems, but that's probably okay, because you couldn't use them there anyway. If you really do need the documentation for a system call or library function, many organizations have put their manpages on the Web; a quick search of AltaVista for +<KBDCLASS="command">crypt(3)</KBD> <KBDCLASS="command">+manual</KBD> will find many copies.</P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="684"TITLE="footer"><TABLEWIDTH="684"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="228"><ACLASS="sect1"HREF="prf2_03.htm"TITLE="Other Books"><IMGSRC="../gifs/txtpreva.gif"ALT="Previous: Other Books"BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="228"><ACLASS="book"HREF="index.htm"TITLE="Perl Cookbook"><IMGSRC="../gifs/txthome.gif"ALT="Perl Cookbook"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="228"><ACLASS="sect1"HREF="prf2_05.htm"TITLE="We'd Like to Hear from You"><IMGSRC="../gifs/txtnexta.gif"ALT="Next: We'd Like to Hear from You"BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="228">Other Books</TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="228"><ACLASS="index"HREF="index/index.htm"TITLE="Book Index"><IMGSRC="../gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="228">We'd Like to Hear from You</TD></TR></TABLE><HRALIGN="LEFT"WIDTH="684"TITLE="footer"><FONTSIZE="-1"></DIV<!-- LIBRARY NAV BAR --> <img src="../gifs/smnavbar.gif" usemap="#library-map" border="0" alt="Library Navigation Links"><p> <a href="copyrght.htm">Copyright © 2002</a> O'Reilly & 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 + -