Synopses & Reviews
Perl is a versatile, powerful programming language used in a variety of disciplines, ranging from system administration to web programming to database manipulation. One slogan of Perl is that it makes easy things easy and hard things possible. This book is about making the leap from the easy things to the hard ones.
Learning Perl Objects, References & Modules offers a gentle but thorough introduction to advanced programming in Perl. Written by the authors of the best-selling Learning Perl, this book picks up where that book left off.
- Packages and namespaces
- References and scoping
- Manipulating complex data structures
- Object-oriented programming
- Writing and using modules
- Contributing to CPAN
Following the successful format of Learning Perl
, each chapter in the book is designed to be small enough to be read in just an hour or two, ending with a series of exercises to help you practice what you've learned. To use the book, you just need to be familiar with the material in Learning Perl and have ambition to go further.
Perl is a different language to different people. It is a quick scripting tool for some, and a fully-featured object-oriented language for others. It is used for everything from performing quick global replacements on text files, to crunching huge, complex sets of scientific data that take weeks to process. Perl is what you make of it. But regardless of what you use Perl for, this book helps you do it more effectively, efficiently, and elegantly.
Learning Perl Objects, References & Modules is about learning to use Perl as a programming language, and not just a scripting language. This is the book that separates the Perl dabbler from the Perl programmer.
"Learning Perl Objects, References & Modules offers a gentle but thorough introduction to advanced programming in Perl. Written by the authors of the best-selling "Learning Perl, this book picks up where that book left off. Topics include: Packages and namespacesReferences and scopingManipulating complex data structuresObject-oriented programmingWriting and using modulesContributing to CPANFollowing the successful format of "Learning Perl, each chapter in the book is designed to be small enough to be read in just an hour or two, ending with a series of exercises to help you practice what you've learned. To use the book, you just need to be familiar with the material in "Learning Perl and have ambition to go further. Perl is a different language to different people. It is a quick scripting tool for some, and a fully-featured object-oriented language for others. It is used for everything from performing quick global replacements on text files, to crunching huge, complex sets of scientific data that take weeks to process. Perl is what you make of it. But regardless of what you use Perl for, this book helps you do it more effectively, efficiently, and elegantly.
About the Author
Randal L. Schwartz is a two-decade veteran of the software industry. He is skilled in software design, system administration, security, technical writing, and training. Randal has coauthored the "must-have" standards: Programming Perl, Learning Perl, Learning Perl for Win32 Systems, and Effective Perl Learning, and is a regular columnist for WebTechniques, PerformanceComputing, SysAdmin, and Linux magazines.
He is also a frequent contributor to the Perl newsgroups, and has moderated comp.lang.perl.announce since its inception. His offbeat humor and technical mastery have reached legendary proportions worldwide (but he probably started some of those legends himself). Randal's desire to give back to the Perl community inspired him to help create and provide initial funding for The Perl Institute. He is also a founding board member of the Perl Mongers (perl.org), the worldwide Perl grassroots advocacy organization. Since 1985, Randal has owned and operated Stonehenge Consulting Services, Inc. Randal can be reached for comment at firstname.lastname@example.org or (503) 777-0095, and welcomes questions on Perl and other related topics.
Tom Phoenix has been working in the field of education since 1982. After more than thirteen years of dissections, explosions, work with interesting animals, and high-voltage sparks during his work at a science museum, he started teaching Perl classes for Stonehenge Consulting Services, where he's worked since 1996. Since then, he has traveled to many interesting locations, so you might see him soon at a Perl Mongers' meeting. When he has time, he answers questions on Usenet's comp.lang.perl.misc and comp.lang.perl.moderated newsgroups, and contributes to the development and usefulness of Perl. Besides his work with Perl, Perl hackers, and related topics, Tom spends his time on amateur cryptography and speaking Esperanto. His home is in Portland, Oregon.
Table of Contents
Foreword; Preface; Structure of This Book; Conventions Used in This Book; Comments and Questions; Acknowledgments; Chapter 1: Introduction; 1.1 What Should You Know Already?; 1.2 What About All Those Footnotes?; 1.3 What's with the Exercises?; 1.4 What if I'm a Perl Course Instructor?; Chapter 2: Building Larger Programs; 2.1 The Cure for the Common Code; 2.2 Inserting Code with eval; 2.3 Using do; 2.4 Using require; 2.5 require and @INC; 2.6 The Problem of Namespace Collisions; 2.7 Packages as Namespace Separators; 2.8 Scope of a Package Directive; 2.9 Packages and Lexicals; 2.10 Exercises; Chapter 3: Introduction to References; 3.1 Performing the Same Task on Many Arrays; 3.2 Taking a Reference to an Array; 3.3 Dereferencing the Array Reference; 3.4 Dropping Those Braces; 3.5 Modifying the Array; 3.6 Nested Data Structures; 3.7 Simplifying Nested Element References with Arrows; 3.8 References to Hashes; 3.9 Exercises; Chapter 4: References and Scoping; 4.1 More than One Reference to Data; 4.2 What if That Was the Name?; 4.3 Reference Counting and Nested Data Structures; 4.4 When Reference Counting Goes Bad; 4.5 Creating an Anonymous Array Directly; 4.6 Creating an Anonymous Hash; 4.7 Autovivification; 4.8 Autovivification and Hashes; 4.9 Exercises; Chapter 5: Manipulating Complex Data Structures; 5.1 Using the Debugger to View Complex Data; 5.2 Viewing Complex Data with Data::Dumper; 5.3 Storing Complex Data with Storable; 5.4 The map and grep Operators; 5.5 Using map; 5.6 Applying a Bit of Indirection; 5.7 Selecting and Altering Complex Data; 5.8 Exercises; Chapter 6: Subroutine References; 6.1 Referencing a Named Subroutine; 6.2 Anonymous Subroutines; 6.3 Callbacks; 6.4 Closures; 6.5 Returning a Subroutine from a Subroutine; 6.6 Closure Variables as Inputs; 6.7 Closure Variables as Static Local Variables; 6.8 Exercise; Chapter 7: Practical Reference Tricks; 7.1 Review of Sorting; 7.2 Sorting with Indices; 7.3 Sorting Efficiently; 7.4 The Schwartzian Transform; 7.5 Recursively Defined Data; 7.6 Building Recursively Defined Data; 7.7 Displaying Recursively Defined Data; 7.8 Exercises; Chapter 8: Introduction to Objects; 8.1 If We Could Talk to the Animals...; 8.2 Introducing the Method Invocation Arrow; 8.3 The Extra Parameter of Method Invocation; 8.4 Calling a Second Method to Simplify Things; 8.5 A Few Notes About @ISA; 8.6 Overriding the Methods; 8.7 Starting the Search from a Different Place; 8.8 The SUPER Way of Doing Things; 8.9 What to Do with @_; 8.10 Where We Are So Far...; 8.11 Exercises; Chapter 9: Objects with Data; 9.1 A Horse Is a Horse, of Course of Course--or Is It?; 9.2 Invoking an Instance Method; 9.3 Accessing the Instance Data; 9.4 How to Build a Horse; 9.5 Inheriting the Constructor; 9.6 Making a Method Work with Either Classes or Instances; 9.7 Adding Parameters to a Method; 9.8 More Interesting Instances; 9.9 A Horse of a Different Color; 9.10 Getting Your Deposit Back; 9.11 Don't Look Inside the Box; 9.12 Faster Getters and Setters; 9.13 Getters That Double as Setters; 9.14 Restricting a Method to Class-Only or Instance-Only; 9.15 Exercise; Chapter 10: Object Destruction; 10.1 Nested Object Destruction; 10.2 Beating a Dead Horse; 10.3 Indirect Object Notation; 10.4 Additional Instance Variables in Subclasses; 10.5 Using Class Variables; 10.6 Weakening the Argument; 10.7 Exercise; Chapter 11: Some Advanced Object Topics; 11.1 UNIVERSAL Methods; 11.2 Testing Your Objects for Good Behavior; 11.3 AUTOLOAD as a Last Resort; 11.4 Using AUTOLOAD for Accessors; 11.5 Creating Getters and Setters More Easily; 11.6 Multiple Inheritance; 11.7 References to Filehandles; 11.8 Exercise; Chapter 12: Using Modules; 12.1 Sample Function-Oriented Interface: File::Basename; 12.2 Selecting What to Import; 12.3 Sample Object-Oriented Interface: File::Spec; 12.4 A More Typical Object-Oriented Module: Math::BigInt; 12.5 The Differences Between OO and Non-OO Modules; 12.6 What use Is Doing; 12.7 Setting the Path at the Right Time; 12.8 Importing with Exporter; 12.9 @EXPORT and @EXPORT_OK; 12.10 Exporting in a Primarily OO Module; 12.11 Custom Import Routines; 12.12 Exercise; Chapter 13: Writing a Distribution; 13.1 Starting with h2xs; 13.2 Looking at the Templates; 13.3 The Prototype Module Itself; 13.4 Embedded Documentation; 13.5 Controlling the Distribution with Makefile.PL; 13.6 Alternate Installation Locations (PREFIX=...); 13.7 Trivial make test; 13.8 Trivial make install; 13.9 Trivial make dist; 13.10 Using the Alternate Library Location; 13.11 Exercise; Chapter 14: Essential Testing; 14.1 What the Test Harness Does; 14.2 Writing Tests with Test::Simple; 14.3 Writing Tests with Test::More; 14.4 Conditional Tests; 14.5 More Complex Tests (Multiple Test Scripts); 14.6 Testing Things That Write to STDOUT and STDERR; 14.7 Exercise; Chapter 15: Contributing to CPAN; 15.1 The Comprehensive Perl Archive Network; 15.2 Getting Prepared; 15.3 Preparing Your Distribution; 15.4 Uploading Your Distribution; 15.5 Announcing the Module; 15.6 Testing on Multiple Platforms; 15.7 Consider Writing an Article or Giving a Talk; 15.8 Exercise; Answers to Exercises; Answers for Chapter 2; Answers for Chapter 3; Answers for Chapter 4; Answers for Chapter 5; Answer for Chapter 6; Answers for Chapter 7; Answers for Chapter 8; Answer for Chapter 9; Answer for Chapter 10; Answer for Chapter 11; Answer for Chapter 12; Answers for Chapters 13-15; Colophon;