📄 ch00_01.htm
字号:
<html><head><title>Preface (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 & Associates, Inc."><meta name="DC.Source" content="" scheme="ISBN"><meta name="DC.Subject.Keyword" content=""><meta name="DC.Title" content="Preface"><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"></td><td align="center" valign="top" width="171"><a href="index.htm"></a></td><td align="right" valign="top" width="172"><a href="ch00_02.htm"><img src="../gifs/txtnexta.gif" alt="Next" border="0"></a></td></tr></table></div><hr width="515" align="left"><!-- SECTION BODY --><h1 class="chapter">Preface</h1><h2 class="sect1">0.1. The Pursuit of Happiness</h2><p>Perl is a language for getting your job done.</p><p>Of course, if your job is programming, you can get your job done withany "complete" computer language, theoretically speaking. But we knowfrom experience that computer languages differ not so much in whatthey make <em class="emphasis">possible</em>, but in what they make<em class="emphasis">easy</em>. At one extreme, the so-calledfourth-generation languages make it easy to do some things, but nearlyimpossible to do other things. At the other extreme, so-calledindustrial-strength languages make it equally difficult to do almosteverything.</p><p>Perl is different. In a nutshell, Perl is designed to make the easyjobs easy, without making the hard jobs impossible.</p><p>And what are these "easy jobs" that ought to be easy? The ones you doevery day, of course. You want a language that makes it easy tomanipulate numbers and text, files and directories, computers andnetworks, and especially programs. It should be easy to run externalprograms and scan their output for interesting tidbits. It should beeasy to send those same tidbits off to other programs that can dospecial things with them. It should be easy to develop, modify, anddebug your own programs too. And, of course, it should be easy tocompile and run your programs, and do it portably, on any modernoperating system.</p><p>Perl does all that, and a whole lot more.</p><p><a name="INDEX-1"></a>Initially designed as a glue language for Unix, Perl has long sincespread to most other operating systems. Because it runs nearlyeverywhere, Perl is one of the most portable programming environmentsavailable today. To program C or C++ portably, you have to put in allthose strange <tt class="literal">#ifdef</tt> markings for different operating systems. Toprogram Java portably, you have to understand the idiosyncrasies ofeach new Java implementation. To program a shell script portably, youhave to remember the syntax for each operating system's version of eachcommand and somehow find the common factor that (you hope) workseverywhere. And to program Visual Basic portably, you just need amore flexible definition of the word "portable". <tt class="literal">:-)</tt></p><p>Perl happily avoids such problems while retaining many of thebenefits of these other languages, with some additional magic of itsown. Perl's magic comes from many sources: the utility of its featureset, the inventiveness of the Perl community, and the exuberance of theopen source movement in general. But much of this magic is simplyhybrid vigor; Perl has a mixed heritage and has always vieweddiversity as a strength rather than a weakness. Perl is a "give meyour tired, your poor" language. If you feel like a huddledmass longing to be free, Perl is for you.</p><p>Perl reaches out across cultures. Much of the explosive growth of Perlhas been fueled by the hankerings of former Unix systems programmerswho wanted to take along with them as much of the "old country" as theycould. For them, Perl is the portable distillation of Unix culture, anoasis in the desert of "can't get there from here". On the otherhand, it also works in the other direction: Windows-based webdesigners are often delighted to discover that they can take their Perlprograms and run them unchanged on the company's Unix server.</p><p>Although Perl is especially popular with systems programmers and webdevelopers, that's just because they discovered it first; Perl appealsto a much broader audience. From its small start as a text-processinglanguage, Perl has grown into a sophisticated, general-purposeprogramming language with a rich software development environmentcomplete with debuggers, profilers, cross-referencers, compilers,libraries, syntax-directed editors, and all the rest ofthe trappings of a "real" programming language--if you want them. Butthose are all about making hard things possible, and lots of languagescan do that. Perl is unique in that it never lost its vision forkeeping easy things easy.</p><p>Because Perl is both powerful and accessible, it is being used daily inevery imaginable field, from aerospace engineering to molecularbiology, from mathematics to linguistics, from graphics to documentprocessing, from database manipulation to networkmanagement. Perl is used by people who are desperate to analyze orconvert lots of data quickly, whether you're talking DNA sequences, webpages, or pork belly futures. Indeed, one of the jokes in the Perlcommunity is that the next big stock market crash will probably betriggered by a bug in someone's Perl script. (On the brighter side, anyunemployed stock analysts will still have a marketable skill, so tospeak.)</p><p>There are many reasons for the success of Perl. Perl was a successfulopen source project long before the open source movement got its name.Perl is free, and will always be free. You can use Perl however yousee fit, subject only to a very liberal licensing policy. If you arein business and want to use Perl, go right ahead. You can embed Perlin the commercial applications you write without fee or restriction.And if you have a problem that the Perl community can't fix, you havethe ultimate backstop: the source code itself. The Perl community isnot in the business of renting you their trade secrets in the guise of"upgrades". The Perl community will never "go out of business" andleave you with an orphaned product.</p><p>It certainly helps that Perl is free software. But that's not enoughto explain the Perl phenomenon since many freeware packages fail tothrive. Perl is not just free; it's also fun. People feel like theycan be creative in Perl because they have freedom of expression: theyget to choose what to optimize for, whether that's computer speed orprogrammer speed, verbosity or conciseness, readability ormaintainability or reusability or portability or learnability orteachability. You can even optimize for obscurity, if you're enteringan Obfuscated Perl Contest.</p><p>Perl can give you all these degrees of freedom because it's a languagewith a split personality. It's simultaneously a very simple languageand a very rich language. Perl has taken good ideas from nearlyeverywhere and installed them into an easy-to-use mental framework.To those who merely like it, Perl is the <em class="emphasis">Practical Extraction andReport Language</em>. To those who love it, Perl is the <em class="emphasis">PathologicallyEclectic Rubbish Lister</em>. And to the minimalists in the crowd, Perlseems like a pointless exercise in redundancy. But that's okay. Theworld needs a few reductionists (mainly as physicists). Reductionistslike to take things apart. The rest of us are just trying to get ittogether.</p><p>There are many ways in which Perl is a simple language. You don't haveto know many special incantations to compile a Perl program--you canjust execute it like a batch file or shell script. The types andstructures used by Perl are easy to use and understand. Perl doesn'timpose arbitrary limitations on your data--your strings and arrays cangrow as large as they like (as long as you have memory), and they'redesigned to scale well as they grow. Instead of forcing you to learnnew syntax and semantics, Perl borrows heavily from other languages youmay already be familiar with (such as C, and <em class="emphasis">awk</em>, and BASIC, andPython, and English, and Greek). In fact, just about any programmercan read a well-written piece of Perl code and have some idea of whatit does.</p><p>Most important, you don't have to know everything there is to know aboutPerl before you can write useful programs. You can learn Perl "smallend first". You can program in Perl Baby-Talk, and we promise not tolaugh. Or more precisely, we promise not to laugh any more than we'dgiggle at a child's creative way of putting things. Many of the ideasin Perl are borrowed from natural language, and one of the best ideas isthat it's okay to use a subset of the language as long as you get your
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -