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

📄 ch01_02.htm

📁 by Randal L. Schwartz and Tom Phoenix ISBN 0-596-00132-0 Third Edition, published July 2001. (See
💻 HTM
📖 第 1 页 / 共 2 页
字号:
write, faster to read, faster to debug, and faster to maintain. Itdoesn't take much programming before you realize that, when theentire subroutine is small enough to fit onscreen all at once, youdon't have to keep scrolling back and forth to see what'sgoing on. Also, since the number of bugs in a program is roughlyproportional to the length of the source code<a href="#FOOTNOTE-17">[17]</a> (rather than being proportional tothe program's functionality), the shorter source in Perl willmean fewer bugs on average.</p><blockquote class="footnote"> <a name="FOOTNOTE-17" /><p>[17]With asharp jump when any one section of the program exceeds the size ofyour screen.</p> </blockquote><p>Like any language, Perl can be"write-only" -- it's possible to write programsthat are impossible to read. But with proper care, you can avoid thiscommon accusation. Yes, sometimes Perl looks like line-noise to theuninitiated, but to the seasoned Perl programmer, it looks likechecksummed line-noise with a mission in life. If you follow theguidelines of this book, your programs should be easy to read andeasy to maintain, and they probably won't win The ObfuscatedPerl Contest.<a href="#FOOTNOTE-18">[18]</a></p><blockquote class="footnote"> <a name="FOOTNOTE-18" /><p>[18]An actual annual event sponsored by the<em class="citetitle">Perl Journal </em>(at <a href="http://www.tpj.com/">http://www.tpj.com/</a> ).</p> </blockquote></div><a name="lperl3-CHP-1-SECT-2.3" /><div class="sect2"><h3 class="sect2">1.2.3. How Did Perl Get to Be So Popular?</h3><p>After playing with Perl a bit, adding stuff here and there, Larryreleased it to the community of Usenet readers, commonly known as"the Net." The users on this ragtag fugitive fleet ofsystems around the world (tens of thousands of them) gave himfeedback, asking for ways to do this, that, or the other thing, manyof which Larry had never envisioned his little Perl handling.</p><p>But as a result, Perl grew, and grew, and grew. It grew in features.It grew in portability. What was once a little language available ononly a couple of Unix systems has now grown to have thousands ofpages of free online documentation, dozens of books, severalmainstream Usenet newsgroups (and a dozen newsgroups and mailinglists outside the mainstream) with an uncountable number of readers,and implementations on nearly every system in use today -- anddon't forget this Llama book as well.</p></div><a name="lperl3-CHP-1-SECT-2.4" /><div class="sect2"><h3 class="sect2">1.2.4. What's Happening with Perl Now?</h3><p>Larry is still in charge of<a name="INDEX-26" />Perl, although the Perl development team isnow made up of approximately thirty key people and a few hundredothers from around the world. And Perl is still growing.</p><p>These days, Perl is still free for you to use. In fact, Larrypromises that it will <em class="emphasis">always</em> be free.(He's a really nice guy; you'd like him.) So go ahead andwrite code in Perl today, without worrying that there will be alicensing fee on your program tomorrow.</p><p>So, if Perl is free, who pays Larry and the other Perl developers?Well, the majority of us contribute to Perl as a labor of love; Perlhelps us, and we help Perl. (If you ever see some way in which youcould improve Perl, we encourage you to send in your contributions,too.) In some cases, though, a person or firm has paid someone to dosome development work. This may be because they needed some newfunctionality badly enough to pay for it, or because they wanted tomake the world a better place.</p><p>Larry doesn't write all of the code these days, but he stillguides the development and makes the big decisions. One of the mostimportant rules he's given us is this one: "Common thingsshould be easy; advanced things should at least be possible."</p><p>Because of that rule, you can be sure that anything that you need todo frequently will have a shortcut in Perl. In fact, by the end ofthis book, you'll probably be using at least ten shortcuts in atypical ten-line program. That is the sort of thing that makes Perleasier to use, at the price of being harder to learn.<a name="INDEX-27" /></p></div><a name="lperl3-CHP-1-SECT-2.5" /><div class="sect2"><h3 class="sect2">1.2.5. What's Perl Really Good For?</h3><p><a name="INDEX-28" />Perl is good for quick-and-dirtyprograms that you whip up in three minutes. Perl is also good forlong-and-extensive programs that will take a dozen programmers threeyears to finish. Of course, you'll probably find yourselfwriting many programs that take you less than an hour to complete,from the initial plan to the fully tested code.</p><p>Perl is optimized for problems which are about 90% working with textand about 10% everything else. That description seems to fit mostprogramming tasks that pop up these days. In a perfect world, everyprogrammer could know every language; you'd always be able tochoose the best language for each project. Most of the time,you'd choose Perl.<a href="#FOOTNOTE-19">[19]</a></p><blockquote class="footnote"> <a name="FOOTNOTE-19" /><p>[19]Don't just take ourword for it, though. If you want to know whether Perl is better thanlanguage X, learn them both and try them both, then see which one youuse most often. That's the one that's best for you. Inthe end, you'll understand Perl better because of your study oflanguage X, and vice versa, so it will be time well spent.</p></blockquote><p>Although the Web wasn't even a twinkle in TimBerners-Lee's eye when Larry created Perl, it was a marriagemade on the Net. Some claim that the deployment of Perl in the early1990s permitted lots of content to be moved into HTML format veryrapidly, and the Web couldn't exist without content. Of course,Perl is the darling language for small CGI scripting (programs run bya web server) as well -- so much so that many of the uninformedstill make statements like "Isn't CGI just Perl?"or "Why would you use Perl other than for CGI?" We findthose statements amusing.</p></div><a name="lperl3-CHP-1-SECT-2.6" /><div class="sect2"><h3 class="sect2">1.2.6. What Is Perl Not Good For?</h3><p>So, if it's good for so many things, what is Perl<em class="emphasis">not</em> good for? Well, you shouldn't choosePerl if you're trying to make an <em class="firstterm">opaquebinary</em>. That's a program that you could give awayor sell to someone who then can't see your secret algorithms inthe source, and thus can't help you to maintain or debug yourcode either. When you give someone your Perl program, you'llnormally be giving them the source, not an opaque binary.</p><p>If you're wishing for an opaque binary, though, we have to tellyou that they don't exist. If someone can install and run yourprogram, they can turn it back into source code. Granted, thiswon't necessarily be the same source that you started with, butit will be some kind of source code. The real way to keep your secretalgorithm a secret is, alas, to apply the proper number of attorneys;they can write a license that says "you can do<em class="emphasis">this</em> with the code, but you can't do<em class="emphasis">that</em>. And if you break our rules, we'vegot the proper number of attorneys to ensure that you'll regretit."</p><p>If you think you really want to compile your Perl code to make abinary, though, see <a href="ch01_04.htm#lperl3-CHP-1-SECT-4.3">Section 1.4.3, "But How Do I Compile Perl?"</a> later in thischapter.</p></div><hr width="684" align="left" /><div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch01_01.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="ch01_03.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">1. Introduction</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">1.3. How Can I Get Perl?</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 + -