Chapter 1. Introduction

Welcome to next step in your understanding of Perl. You’re probably here either because you want to learn to write programs that are more than 100 lines long or because your boss has told you to do so.

See, our Learning Perl book was great because it introduced the use of Perl for short and medium programs (which is most of the programming done in Perl, we’ve observed). But, to avoid having “the Llama book” be as big and intimidating as “the Camel book,” we left a lot of information out, deliberately and carefully.

In the pages that follow, you can get “the rest of the story” in the same style as our friendly Llama book. It covers what you need to write programs that are 100 to 10,000 lines long.

For example, you’ll learn how to work with multiple programmers on the same project. This is great, because unless you work 35 hours each day, you’ll need some help with larger tasks. You’ll also need to ensure that your code all fits with the other code as it is developed for the final application.

This book will also show you how to deal with larger and more complex data structures, such as what we might casually call a “hash of hashes” or an “array of arrays of hashes of arrays.”

And then there’s the buzzworthy notion of object-oriented programming, which allows parts of your code (or hopefully code from others) to be reused with minor or major variations within the same program. The book will cover that as well, even if you’ve never seen objects before.

An important aspect of working in teams is having a release cycle and tests for unit and integration testing. You’ll learn the basics of packaging your code as a distribution and providing unit tests for that distribution, both for development and for verifying that your code works in the ultimate end environment.

Hopefully, just as was promised and delivered in Learning Perl, you’ll be entertained along the way by interesting examples and bad puns. (We’ve sent Fred and Barney and Betty and Wilma home, though. A new cast of characters will take the starring roles.)

What Should You Know Already?

We’ll presume that you’ve already read Learning Perl, or at least pretend you have, and that you’ve played enough with Perl to already have those basics down. For example, you won’t see an explanation in this book that shows how to access the elements of an array or return a value from a subroutine.

Make sure you know the following things:

  • How to run a Perl program on your system

  • Scalars

  • Arrays

  • Hashes

  • Control structures such as while, if, for, and foreach

  • Subroutines

  • Perl operators such as grep, map, sort, and print

  • File manipulation such as open, file reading, and -x (file tests)

You might pick up deeper insight into these topics in this book, but we’re going to presume you know the basics.

What About All Those Footnotes?

Like Learning Perl, this book relegates some of the more esoteric items out of the way for the first reading and places those items in footnotes.[3] You should skip those the first time through and pick them up on a rereading. You will not find anything in a footnote that is needed to understand any of the later material.

What’s with the Exercises?

Hands-on training gets the job done better. The best way to provide this training is with a series of one or more exercises after every half-hour to hour of presentation. Of course, if you’re a speed reader, the end of the chapter may come a bit sooner than a half hour. Slow down. Take a breather. But do the exercises.

Each exercise has a “minutes to complete” rating. This rating hits the midpoint of the bell curve but don’t feel bad if you take significantly longer or shorter. Sometimes it’s just a matter of how many times you’ve faced similar programming tasks in your studies or jobs. Use the numbers merely as a guideline.

Every exercise has its answer in Appendix A. Again, try not to peek; you’ll ruin the value of the exercise.

What if I’m a Perl Course Instructor?

If you’re a Perl instructor who has decided to use this as your textbook, you should know that each set of exercises is short enough for most students to complete 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 all those little numbers in square brackets were written, we discovered that we don’t know how to add.

So let’s get started. Class begins after you turn the page...



[3] Like this.

Get Learning Perl Objects, References, and Modules now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.