📄 ch37_05.htm
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 37] 37.5 And Now, Perl 5 </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly & Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly & Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:48:56Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-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="ch37_01.htm"TITLE="37. Perl, a Pathologically Eclectic Rubbish Lister"><LINKREL="prev"HREF="ch37_04.htm"TITLE="37.4 Why Learn Perl? #2 "><LINKREL="next"HREF="part06.htm"TITLE="VI. Managing Processes "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch37_04.htm"TITLE="37.4 Why Learn Perl? #2 "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 37.4 Why Learn Perl? #2 "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 37<BR>Perl, a Pathologically Eclectic Rubbish Lister</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="PART"HREF="part06.htm"TITLE="VI. Managing Processes "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: VI. Managing Processes "BORDER="0"></A></TD></TR></TABLE> <HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-9908">37.5 And Now, Perl 5 </A></H2><PCLASS="para">[This article was adapted from the Perl 5 manual pages. -JP]</P><PCLASS="para">Other articles in this chapter were actually written for the previousversion, Perl 4, but they apply to Perl 5 as well. Perl 5 isnearly a complete rewrite of Perl 4. Most Perl 4 scripts will workunder Perl 5. Perl 5 has these new benefits (and more):</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Many usability enhancements</B>: It is now possible to write muchmore readable Perl code (even within regular expressions). Errormessages are more informative; the optional warnings will catch manyof the mistakes a novice might make.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Lexical scoping</B>: Perl variables may now be declared within alexical scope, like "auto" variables in C.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Arbitrarily nested data structures</B>: Any scalar value, includingany array element, may now contain a reference to any other variableor subroutine.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Modularity and reusability</B>: The Perl library is now defined interms of modules that can be easily shared among various packages. Apackage may choose to import all or a portion of a module's publishedinterface. Pragmas (that is, compiler directives) are defined andused by the same mechanism.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Object-oriented programming</B>: A Perl package can function as aclass. Dynamic multiple inheritance and virtual methods are supportedin a straightforward manner and with very little new syntax.Filehandles may now be treated as objects.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Embeddable and extensible</B>: Perl may now be embedded easily inyour C or C++ application, and can either call or be called by yourroutines through a documented interface. The XS preprocessoris provided to make it easy to glue your C or C++ routines into Perl.Dynamic loading of modules is supported.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">POSIX compliant</B>: A major new module is the POSIXmodule, which provides access to all available POSIX routinesand definitions, via object classes where appropriate.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Package constructors and destructors</B>: The new BEGIN andEND blocks provide means to capture control as a package isbeing compiled, and after the program exits. They work just like<EMCLASS="emphasis">awk</EM>'s BEGIN and END when you use the <EMCLASS="emphasis">-p</EM> or<EMCLASS="emphasis">-n</EM> switches.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Multiple simultaneous DBM implementations</B>: A Perl programmay now access DBM, NDBM, SDBM, GDBM, andBerkeley DB database files from the same script simultaneously.</P></LI><LICLASS="listitem"><PCLASS="para"><BCLASS="emphasis.bold">Regular expression enhancements</B>: If you thought Perl 4 regularexpressions were rich and full of incredible features, wait until yousee Perl 5!</P></LI></UL><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">JP</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch37_04.htm"TITLE="37.4 Why Learn Perl? #2 "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 37.4 Why Learn Perl? #2 "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="PART"HREF="part06.htm"TITLE="VI. Managing Processes "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: VI. Managing Processes "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">37.4 Why Learn Perl? #2 </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">VI. Managing Processes </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed & awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -