Preface
Welcome to the sixth edition of Learning Perl, updated for Perl 5.14 and its latest features. This book is still good even if you are still using Perl 5.8 (although, its been a long time since it was released; have you thought about upgrading?).
If youre looking for the best way to spend your first 30 to 45 hours with the Perl programming language, youve found it. In the pages that follow, youll find a carefully paced introduction to the language that is the workhorse of the Internet, as well as the language of choice for system administrators, web hackers, and casual programmers around the world.
We cant give you all of Perl in just a few hours. The books that promise that are probably fibbing a bit. Instead, weve carefully selected a useful subset of Perl for you to learn, good for programs from one to 128 lines long, which end up being about 90% of the programs in use out there. And when youre ready to go on, you can get Intermediate Perl , which picks up where this book leaves off. Weve also included a number of pointers for further education.
Each chapter is small enough so you can read it in an hour or two. Each chapter ends with a series of exercises to help you practice what youve just learned, with the answers in for your reference. Thus, this book is ideally suited for a classroom Introduction to Perl course. We know this directly because the material for this book was lifted almost word-for-word from our flagship Learning Perl course, delivered to thousands of students around the world. However, weve designed the book for self-study as well.
Perl lives as the toolbox for Unix, but you dont have to be a Unix guru, or even a Unix user, to read this book. Unless otherwise noted, everything were saying applies equally well to Windows ActivePerl from ActiveState and pretty much every other modern implementation of Perl.
Although you dont need to know a single thing about Perl to begin reading this book, we recommend that you already have familiarity with basic programming concepts such as variables, loops, subroutines, and arrays, and the all-important editing a source code file with your favorite text editor. We dont spend any time trying to explain those concepts. Although were pleased that weve had many reports of people successfully picking up Learning Perl and grasping Perl as their first programming language, of course we cant promise the same results for everyone.
Typographical Conventions
The following font conventions are used in this book:
Constant width
is used for method names, function names, variables, and attributes. It is also used for code examples.
Constant width bold
is used to indicate user input.
Constant width italic
is used to indicate a replaceable item in code (e.g., filename
, where you are supposed to substitute an actual filename).
Italic
is used for filenames, URLs, hostnames, commands in text, important words on first mention, and emphasis.
Footnotes
are used to attach parenthetical notes that you should not read on your first (or perhaps second or third) reading of this book. Sometimes lies are spoken to simplify the presentation, and the footnotes restore the lie to truth. Often the material in the footnote will be advanced material not even mentioned anywhere else in the book.
[
2 ]
at the start of an exercises text represents our (very rough) estimate of how many minutes you can expect to spend on that particular exercise.
Code Examples
This book is here to help you get your job done. You are invited to copy the code in the book and adapt it for your own needs. Rather than copying by hand, however, we encourage you to download the code from http://www.learning-perl.com.
In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, authors, publisher, and ISBN. For example: Learning Perl , 6th edition, by Randal L. Schwartz, brian d foy, and Tom Phoenix (OReilly). Copyright 2011 Randal L. Schwartz, brian d foy, and Tom Phoenix, 978-1-449-30358-7. If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com
Safari Books Online
Note
Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, download chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other time-saving features.
OReilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from OReilly and other publishers, sign up for free at http://my.safaribooksonline.com.