Book HomeLearning Perl, 3rd EditionSearch this book

Chapter 1. Introduction

Contents:

Questions and Answers
What Does "Perl" Stand For?
How Can I Get Perl?
How Do I Make a Perl Program?
A Whirlwind Tour of Perl
Exercises

Welcome to the Llama book!

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.[4]

[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 enjoyed 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.

1.1. Questions and Answers

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.

1.1.1. Is This the Right Book for You?

If you're anything like us, you're probably standing in a bookstore right now,[5] 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.[6] You've got about two minutes before the bookstore manager comes over to tell you that this isn't a library,[7] 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.

[5]Actually, if you're like us, you're standing in a library, not a bookstore. But we're tightwads.

[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.

[7]Unless it is.

1.1.2. Why Are There So Many Footnotes?

Thank you for noticing. There are a lot of 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.

But it means that we can't honestly say, "The fizzbin operator frobnicates the hoozistatic variables" without a footnote giving the exceptions.[8] 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.)

[8]Except on Tuesdays, during a power outage, when you hold your elbow at a funny angle during the equinox, or when use integer is in effect inside a loop block being called by a prototyped subroutine prior to Perl version 5.6.

Many of the exceptions have to do with 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.)

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).[9]

[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.

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.

1.1.3. What About the Exercises and Their Answers?

The 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.[10] We have carefully crafted these exercises to give you the chance to make mistakes as well.

[10]Not all at once.

It's not that we want you to make mistakes, but you need to have the chance. 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 Appendix A, "Exercise Answers", 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.

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.

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.

1.1.4. What Do Those Numbers Mean at the Start of the Exercise?

Each exercise has a number in square brackets in front of the exercise text, looking something like this:

  1. [2] What does the number 2 inside square brackets mean, when it appears at the start of an exercise's text?

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 Appendix A, "Exercise Answers" to see what our answer looked like.

1.1.5. What If I'm a Perl Course Instructor?

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.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.