Learning Perl Objects, References, and ModulesPerl 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. Topics include:
|
Contents
Exercises | 98 |
Objects with Data | 99 |
Invoking an Instance Method | 100 |
Accessing the Instance Data | 101 |
How to Build a Horse | 102 |
Making a Method Work with Either Classes or Instances | 103 |
Adding Parameters to a Method | 104 |
More Interesting Instances | 105 |
The Problem of Namespace Collisions | 11 |
Packages as Namespace Separators | 12 |
Scope of a Package Directive | 14 |
Packages and Lexicals | 15 |
Introduction to References | 17 |
Taking a Reference to an Array | 19 |
Dereferencing the Array Reference | 20 |
Dropping Those Braces | 21 |
Modifying the Array | 22 |
Nested Data Structures | 23 |
Simplifying Nested Element References with Arrows | 25 |
References to Hashes | 26 |
Exercises | 28 |
References and Scoping | 30 |
What if That Was the Name? | 31 |
Reference Counting and Nested Data Structures | 32 |
When Reference Counting Goes Bad | 34 |
Creating an Anonymous Array Directly | 35 |
Creating an Anonymous Hash | 38 |
Autovivification | 40 |
Autovivification and Hashes | 42 |
Exercises | 44 |
Manipulating Complex Data Structures | 45 |
Dumper | 50 |
Storing Complex Data with Storable | 51 |
The map and grep Operators | 53 |
Using map | 55 |
Applying a Bit of Indirection | 56 |
Selecting and Altering Complex Data | 58 |
Exercises | 59 |
Subroutine References | 61 |
Anonymous Subroutines | 65 |
Callbacks | 67 |
Closures | 68 |
Returning a Subroutine from a Subroutine | 70 |
Closure Variables as Inputs | 73 |
Exercise | 75 |
Practical Reference Tricks | 77 |
Sorting with Indices | 78 |
Sorting Efficiently | 79 |
The Schwartzian Transform | 81 |
Recursively Defined Data | 82 |
Displaying Recursively Defined Data | 85 |
Exercises | 86 |
Introduction to Objects | 88 |
If We Could Talk to the Animals | 89 |
Introducing the Method Invocation Arrow | 90 |
The Extra Parameter of Method Invocation | 91 |
Calling a Second Method to Simplify Things | 92 |
A Few Notes About ISA | 93 |
Overriding the Methods | 94 |
Starting the Search from a Different Place | 96 |
The SUPER Way of Doing Things | 97 |
A Horse of a Different Color | 106 |
Dont Look Inside the Box | 108 |
Faster Getters and Setters | 109 |
Restricting a Method to ClassOnly or InstanceOnly | 110 |
Object Destruction | 112 |
Beating a Dead Horse | 117 |
Indirect Object Notation | 118 |
Additional Instance Variables in Subclasses | 119 |
Using Class Variables | 121 |
Weakening the Argument | 122 |
Exercise | 125 |
Some Advanced Object Topics | 126 |
Testing Your Objects for Good Behavior | 127 |
AUTOLOAD as a Last Resort | 128 |
Using AUTOLOAD for Accessors | 129 |
Creating Getters and Setters More Easily | 130 |
Multiple Inheritance | 132 |
References to Filehandles | 133 |
Exercise | 135 |
Using Modules | 137 |
Selecting What to Import | 138 |
MathBiglnt | 139 |
The Differences Between OO and NonOO Modules | 140 |
Setting the Path at the Right Time | 141 |
Importing with Exporter | 143 |
EXPORT and EXPORT_OK | 144 |
Exporting in a Primarily OO Module | 145 |
Custom Import Routines | 147 |
Writing a Distribution | 148 |
Starting with h2xs | 149 |
The Prototype Module Itself | 152 |
Embedded Documentation | 154 |
Controlling the Distribution with MakefilePL | 158 |
Alternate Installation Locations PREFIX | 159 |
Trivial make test | 160 |
Trivial make install | 161 |
Trivial make dist | 162 |
Exercise | 163 |
Essential Testing | 164 |
What the Test Harness Does | 166 |
Simple | 167 |
More | 168 |
Conditional Tests | 172 |
More Complex Tests Multiple Test Scripts | 173 |
Exercise | 174 |
Contributing to CPAN | 175 |
Getting Prepared | 176 |
Uploading Your Distribution | 177 |
Announcing the Module | 178 |
Exercise | 179 |
Answers to Exercises | 181 |
197 | |
Other editions - View all
Common terms and phrases
all_with_names alpaca anonymous array anonymous hash Answers for Chapter array reference AUTOLOAD basename block bytes callback class method coderef color complex data constructor CPAN create curly braces data structure data2 defined dereference dereferencing destination destructor distribution Dumper element example Exporter filehandle getter Gilligan Ginger Ginger Grant goes grep hash reference Horse install instance variables invocation invoke jacket preserver sunscreen keys Learning Perl lexical variable look lovey.howell.hut Makefile Makefile.PL manpage module multiple inheritance navigation.pl object operator output parameter person Professor professor.hut provisions qw(Animal qw(blue_shirt hat jacket RaceHorse recursive reference count result routine scalar scalar variable Schwartzian Transform Seither shift simple Skipper sort Sself Ssource Storable string sub named sub sound sub speak subroutine syntax take a reference test harness Test::More there's Tom Phoenix total_bytes total_bytes{$source}{$destination total_size tv_horse undef water_bottle weak references write