From brian I have to thank Randal first, since I learned Perl from the first edition of this book, and then had to learn it again when he asked me to start teaching for Stonehenge in 1998. The wheelbarrow was invented by someone who was too lazy to carry things; writing was invented by someone who was too lazy to memorize; Perl was invented by someone who was too lazy to get the job done without inventing a whole new computer language. Answering a question by citing this book and quoting example code does not require permission. How Do I Compile My Perl Program? Informed by their years of success at teaching Perl as consultants, the authors have re-engineered the book to better match the pace and scope appropriate for readers trying to get started with Perl, while retaining the detailed discussion, thorough examples, and eclectic wit for which the book is famous. To the many folks on Usenet who have given me your appreciation and encouragement for my contributions there, thanks.
This is an easiest way to send files to someone who cannot accept them live. This second edition covers recent changes to the language up to version 5. Perl is suitable for almost any task on almost any platform, from short fixes to complete web applications. Years of classroom testing and experience helped shape the book's pace and scope, and this edition is packed with exercises that let you practice the concepts while you follow the text. He needed something with the quickness of coding available in shell or awk programming, and with some of the power of more advanced tools like grep, cut, sort, and sed, without having to resort to a language like C. As we write this March 2011 , there is a lot happening with Perl.
Without it, you may get inconsistent results—some versions of Perl actually abort when they detect a mismatch in the line endings. How Do I Make a Perl Program? What Is Perl Not Good For? But using that is beyond the scope of this book. And finally, our sincerest thanks to our friend Larry Wall, for having the wisdom to share his really cool and powerful toys with the rest of the world so that we can all get our work done just a little bit faster, easier, and with more fun. Footnotes are used to attach parenthetical notes that you should not read on your first or perhaps second or third reading of this book. If you have trouble convincing your admin to install Perl, offer to buy a pizza. The latest version, starting from the stable 5.
Ask your local expert about text editors on your system. How to Contact Us We have tested and verified all the information in this book to the best of our abilities, but you may find that features have changed or that we have let errors slip through the production of the book. Also to my many students, who have shown me with their questions and befuddled looks when I needed to try a new way of expressing a concept. If you skipped our advice about Unicode from the Preface, you might want to go through Appendix C to learn more about Unicode. Scalar Variables A variable is a name for a container that holds one or more values. Each chapter in this guide contains exercises to help you practice what you learn as you learn it.
That means that the code is quite dense; a Perl program may be around a quarter to three-quarters as long as the corresponding program in C. Math geeks know that the result would be a complex number. Perl is quick, fun, and eminently useful. Through various accidents and tangents, it turned out that as Perl 5 hotted up again, Perl 6 bogged down. The first thing to do when you find a bug is to check the documentation§ again.
For the third edition of this book, Linda Mui was our editor, and I still thank her, for her patience in pointing out which jokes and footnotes were most excessive, while pointing out that she is in no way to blame for the ones that remain. You have to bite the bullet sometime, so it might as well be now. Perl is a language for getting your job done. Every line of output should end with a newline character. If an operator expects a number like + does , Perl will see the value as a number. The Camel book contains the complete reference information, some tutorial stuff, and a bunch of miscellaneous information about Perl.
Each chapter is small enough so you can read it in an hour or two. As always, a special thanks to Lyle and Jack, for teaching me nearly everything I know about writing. As of this writing, there are five of them, but they change from time to time. But all of us love Perl, so nobody likes to let a bug escape our notice. You already know about variables and subroutines and the like, but you just need to see how Perl does it. You folks have contributed many different viewpoints on teaching methods that I would never have seen.
Perl is suitable for almost any task on almost any platform, from short fixes to complete web applications. The resulting longer string is then available for further computation or assignment to a variable. In some cases, you may need to compose the program on one machine, then transfer it to another to run it. § Well, Perl will sometimes use internal integers in ways that are not visible to the programmer. Author brian d foy Mastering Perl provides a sophisticated introduction to this new programming language. Other books may teach you to program in Perl 6, but this book will turn you into a Perl 6 programmer. Using Simple Patterns Unicode Properties About Metacharacters Simple Quantifiers Grouping in Patterns Alternatives Character Classes Character Class Shortcuts Negating the Shortcuts Exercises 121 122 123 123 124 125 127 128 129 131 131 8.