20 of 22 people found the following review helpful
- Published on Amazon.com
I first tried to learn Perl by using the other O'Reilly book, "Programming Perl". I was completely lost. Then I found this book and my second attempt was much more successful. This book is great for self-teaching, and the book chapters should be read in order as each chapter builds on previous ones. Each chapter has plenty of good programming exercises with answers in the back of the book. I review this book in the context of the table of contents.
Chapter 1. Introduction
This chapter answers basic questions such as how to get and install Perl, how to construct a basic Perl program, and then takes you on a whirlwind tour of Perl.
Chapter 2. Scalar Data
As a general rule, when Perl has just one of something, that's a scalar, which is the topic of this chapter.
Chapter 3. Lists and Arrays
If a scalar is the "singular" in Perl, as described at the beginning of Chapter 2, the "plural" in Perl is represented by lists and arrays. A list is an ordered collection of scalars. An array is a variable that contains a list. In Perl, the two terms are often used as if they're interchangeable. But, to be accurate, the list is the data, and the array is the variable. You learn about these differences through practical code examples in this chapter.
Chapter 4. Subroutines
You've now seen and used some of the built-in system functions, such as chomp, reverse, and print. But, as other languages do, Perl has the ability to make subroutines. The name of a subroutine is another Perl identifier occasionally with an optional ampersand in front. There's a rule about when you can omit the ampersand and when you cannot, and that rule is discussed.
Chapter 5. Input and Output
This chapter covers the 80% of the I/O you'll need for most programs. If you're familiar with the workings of standard input, output, and error streams, you're ahead of the game. If not, you get you caught up by the end of this chapter.
Chapter 6. Hashes
In this chapter, you will see a feature that makes Perl one of the world's great programming languages--hashes. Though hashes are a powerful and useful feature, you may have used other powerful languages for years without ever hearing of hashes. But you'll use hashes in nearly every Perl program you'll write from now on; they're that important.
A hash is a data structure like an array, in that it can hold any number of values and retrieve these values at will. However, instead of indexing the values by number, as in arrays, you look up the values by name. That is, the indices aren't numbers but are arbitrary unique strings.
Chapter 7. In the World of Regular Expressions
Perl has many features that set it apart from other languages. Of all those features, one of the most important is its strong support for regular expressions. These allow fast, flexible, and reliable string handling. But that power comes at a price. Regular expressions are tiny programs in their own special language, built inside Perl. This means that you're about to learn another programming language, although, fortunately, it's a simple one. In this chapter, you'll visit the world of regular expressions, where, for the most part, you can forget about the world of Perl.
Chapter 8. Matching with Regular Expressions
In the previous chapter, you visited the world of regular expressions. Now you'll see how that world fits into the world of Perl.
Chapter 9. Processing Text with Regular Expressions
You can use regular expressions to change text, too. So far, the book has only shown you how to match a pattern. Now, you'll learn how to use patterns to locate the parts of strings that you want to change.
Chapter 10. More Control Structures
In this chapter, you'll see some alternative ways to write Perl code. For the most part, these techniques don't make the language more powerful, but they make it easier or more convenient to get the job done. You don't have to use these techniques in your own code, but don't skip this chapter. You're certain to see these control structures in other people's code, sooner or later.
Chapter 11. File Tests
Earlier, this book showed how to open a filehandle for output. Normally, that will create a new file, wiping out any existing file with the same name. Perhaps you want to check that there isn't a file by that name. Perhaps you need to know how old a given file is, or perhaps you want to go through a list of files to find which ones are larger than a certain number of bytes and not accessed for a certain amount of time. Perl has a complete set of tests you can use to find information about files, and that is the topic of this chapter.
Chapter 12. Directory Operations
The files created in the previous chapter were generally in the same place as your program. But modern operating systems let you organize files into directories, allowing you to keep your MP3 files away from your important work files so you don't accidentally send an MP3 file to your boss. In this chapter you'll see how Perl lets you manipulate these directories directly, in ways that are even fairly portable from one operating system to another.
Chapter 13. Strings and Sorting
Perl is designed to be good at solving programming problems that are about 90% working with text and 10% everything else. So it's no surprise that Perl has strong text-processing abilities, including all that can be done with regular expressions. But sometimes the regular expression engine is too fancy, and you need a simpler way of working with a string, as you'll see in this chapter.
Chapter 14. Process Management
One of the best parts of being a programmer is launching someone else's code so you don't have to write it yourself. This chapter shows how to manage your child processes by launching other programs directly from Perl. The examples in this chapter are primarily Unix-based; if you have a non-Unix system, expect to see some differences.
Chapter 15. Perl Modules
There is a lot more to Perl than what is in this book, and there are a lot of people doing a lot of interesting things with Perl. If there is a problem to solve, then somebody has probably already solved it and made their solution available on the Comprehensive Perl Archive Network (CPAN), which is a worldwide collection of servers and mirrors containing thousands of modules of reusable Perl code. If you want to learn how to write modules, consult the "Alpaca book". In this chapter, you learn how to use modules that already exist.
Chapter 16. Some Advanced Perl Techniques
The techniques in this chapter are only "advanced" in the sense that they aren't necessary for beginners. The first time you read this book, you may want to either skip or skim this chapter so you can get right to using Perl. Then come back to it later when you're ready to get more out of Perl.
Appendix A - Exercise Answers
Appendix B - Beyond the Llama