📄 ch01_01.htm
字号:
<html><head><title>Introduction (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 & 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="ch00_05.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="ch01_02.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr></table></div>
<h1 class="chapter">Chapter 1. Introduction</h1>
<div class="htmltoc"><h4 class="tochead">Contents:</h4>
<p> <a href="#lperl3-CHP-1-SECT-1">Questions and Answers</a><br />
<a href="ch01_02.htm">What Does "Perl" Stand For?</a><br />
<a href="ch01_03.htm">How Can I Get Perl?</a><br />
<a href="ch01_04.htm">How Do I Make a Perl Program?</a><br />
<a href="ch01_05.htm">A Whirlwind Tour of Perl</a><br />
<a href="ch01_06.htm">Exercises</a><br /></p></div>
<p>Welcome to the <a name="INDEX-4" /></a>Llama book!
</p>
<p>This is the third edition of a book that has been enjoyed by half a
million readers since 1993. At least, we hope they've enjoyed
it. It's a sure thing that we've enjoyed writing
it.<a href="#FOOTNOTE-4">[4]</a>
</p><blockquote class="footnote"> <a name="FOOTNOTE-4" /></a><p>[4]To be sure, the first edition was written by
Randal L. Schwartz, the second by Randal L. Schwartz and Tom
Christiansen, and this one by Randal L. Schwartz and Tom Phoenix. So,
whenever we say "we" in this edition, we mean those last
two. Now, if you're wondering how we can say that we've
<em class="emphasis">enjoyed</em> writing it (in the past tense) when
we're still on the first page, that's easy: we started at
the end, and worked our way backwards. It sounds like a strange way
to do it, we know. But, honestly, once we finished writing the index,
the rest was hardly any trouble at all.</p> </blockquote>
<div class="sect1"><a name="lperl3-CHP-1-SECT-1" /></a>
<h2 class="sect1">1.1. Questions and Answers</h2>
<p>You probably have some questions about Perl, and maybe even some
about this book; especially if you've already flipped through
the book to see what's coming. So we'll use this chapter
to answer them.
</p>
<a name="lperl3-CHP-1-SECT-1.1" /></a><div class="sect2">
<h3 class="sect2">1.1.1. Is This the Right Book for You?</h3>
<p>If you're anything like us, you're probably standing in a
bookstore right now,<a href="#FOOTNOTE-5">[5]</a> wondering
whether you should get this Llama book and learn Perl, or maybe that
book over there and learn some language named after a snake, or a
beverage, or a letter of the alphabet.<a href="#FOOTNOTE-6">[6]</a> You've got about two minutes before
the bookstore manager comes over to tell you that this isn't a
library,<a href="#FOOTNOTE-7">[7]</a> and you need to buy something or get out. Maybe you want
to use these two minutes to see a quick Perl program, so you'll
know something about how powerful Perl is and what it can do. In that
case, you should check out the whirlwind tour of Perl, later in this
chapter.
</p><blockquote class="footnote"> <a name="FOOTNOTE-5" /></a><p>[5]Actually, if you're like
us, you're standing in a <em class="emphasis">library</em>, not a
bookstore. But we're tightwads.</p> </blockquote><blockquote class="footnote"> <a name="FOOTNOTE-6" /></a><p>[6]Before you
write to tell us that it's a comedy troupe, not a snake, we
should really explain that we're dyslexically thinking of
CORBA.</p> </blockquote><blockquote class="footnote"> <a name="FOOTNOTE-7" /></a><p>[7]Unless it <em class="emphasis">is</em>.</p>
</blockquote>
</div>
<a name="lperl3-CHP-1-SECT-1.2" /></a><div class="sect2">
<h3 class="sect2">1.1.2. Why Are There So Many Footnotes?</h3>
<p>Thank you for noticing. There <em class="emphasis">are</em> a lot of
<a name="INDEX-5" /></a>footnotes in this book. Ignore them.
They're needed because Perl is chock-full of exceptions to its
rules. This is a good thing, as real life is chock-full of exceptions
to rules.
</p>
<p>But it means that we can't honestly say, "The fizzbin
operator frobnicates the hoozistatic variables" without a
footnote giving the exceptions.<a href="#FOOTNOTE-8">[8]</a> We're pretty
honest, so we have to write the footnotes. But you can be honest
without reading them. (It's funny how that works out.)
</p><blockquote class="footnote"> <a name="FOOTNOTE-8" /></a><p>[8]Except on Tuesdays,
during a power outage, when you hold your elbow at a funny angle
during the equinox, or when <tt class="literal">use integer</tt> is in
effect inside a loop block being called by a prototyped subroutine
prior to Perl version 5.6.</p> </blockquote>
<p>Many of the exceptions have to do with
<a name="INDEX-6" /></a>
<a name="INDEX-7" /></a>
<a name="INDEX-8" /></a>portability. Perl began on Unix systems,
and it still has deep roots in Unix. But wherever possible,
we've tried to show when something may behave unexpectedly,
whether that's because it's running on a non-Unix system,
or for another reason. We hope that readers who know nothing about
Unix will nevertheless find this book a good introduction to Perl.
(And they'll learn a little about Unix along the way, at no
extra charge.)
</p>
<p>And many of the other exceptions have to do with the old
"80/20" rule. By that we mean that 80% of the behavior of
Perl can be described in 20% of the documentation, and the other 20
percent of the behavior takes up the other 80% of the documentation.
So to keep this book small, we'll talk about the most common,
easy-to-talk-about behavior in the main text, and hint in the
direction of the other stuff in the footnotes (which are in a smaller
font, so we can say more in the same space).<a href="#FOOTNOTE-9">[9]</a>
</p><blockquote class="footnote"> <a name="FOOTNOTE-9" /></a><p>[9]We even
discussed doing the entire book as a footnote to save the pagecount,
but footnotes on footnotes started to get a bit crazy.</p>
</blockquote>
<p>Once you've read the book all the way through without reading
the footnotes, you'll probably want to look back at some
sections for reference. At that point, or if you become unbearably
curious along the way, go ahead and read the notes. A lot of them are
just computer jokes anyway.
</p>
</div>
<a name="lperl3-CHP-1-SECT-1.3" /></a><div class="sect2">
<h3 class="sect2">1.1.3. What About the Exercises and Their Answers?</h3>
<p>The <a name="INDEX-9" /></a>exercises are at the end of each chapter
because, between the two of us, we've presented this same
course material to several thousand students.<a href="#FOOTNOTE-10">[10]</a> We have carefully crafted these exercises
to give you the chance to make mistakes as well.
</p><blockquote class="footnote"> <a name="FOOTNOTE-10" /></a><p>[10]Not all
at once.</p> </blockquote>
<p>It's not that we <em class="emphasis">want</em> you to make
mistakes, but you need to have the <em class="emphasis">chance</em>.
That's because you are going to make most of these mistakes
during your Perl programming career, and it may as well be now. Any
mistake that you make while reading this book you won't make
again when you're writing a program on a deadline. And
we're always here to help you out if something goes wrong, in
the form of <a href="appa_01.htm">Appendix A, "Exercise Answers"</a>, which has our answer for
each exercise and a little text to go with it, explaining the
mistakes you made and a few you didn't. Check out the answers
when you're done with the exercises.
</p>
<p>Try not to peek at the answer until you've given the problem a
good try, though. You'll learn better if you figure it out
rather than if you read about it.
</p>
<p>Even if you never make any mistakes, you should look at the answers
when you're done; the accompanying text will point out some
details of the program that might not be obvious at first.
</p>
</div>
<a name="lperl3-CHP-1-SECT-1.4" /></a><div class="sect2">
<h3 class="sect2">1.1.4. What Do Those Numbers Mean at the Start of the Exercise?</h3>
<p>Each exercise has a number in square brackets in front of the
exercise text, looking something like this:
</p>
<ol><li>
<p>[2] What does the number 2 inside square brackets mean, when it
appears at the start of an exercise's text?
</p>
</li></ol>
<p>That number is our (very rough) estimate of how many minutes you can
expect to spend on that particular exercise. It's rough, so
don't be too surprised if you're all done (with writing,
testing, and debugging) in half that time, or not done in twice that
long. On the other hand, if you're really stuck, we won't
tell anyone that you peeked at <a href="appa_01.htm">Appendix A, "Exercise Answers"</a> to see
what our answer looked like.
</p>
</div>
<a name="lperl3-CHP-1-SECT-1.5" /></a><div class="sect2">
<h3 class="sect2">1.1.5. What If I'm a Perl Course Instructor?</h3>
<p>If you're a Perl instructor who has decided to use this as your
textbook (as many have over the years), you should know that
we've tried to make each set of exercises short enough that
most students could do the whole set in 45 minutes to an hour, with a
little time left over for a break. Some chapters' exercises
should be quicker, and some may take longer. That's because,
once we had written all of those little numbers in square brackets,
we discovered that we don't know how to add.
</p>
</div>
</div>
<hr width="684" align="left" />
<div class="navbar"><table width="684" border="0"><tr><td align="left" valign="top" width="228"><a href="ch00_05.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_02.htm"><img alt="Next" border="0" src="../gifs/txtnexta.gif" /></a></td></tr><tr><td align="left" valign="top" width="228">0.5. Acknowledgments</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.2. What Does "Perl" Stand For?</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 © 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 + -