Learning Perl Objects, References, and Modules"O'Reilly Media, Inc.", 2003 - 205 ページ 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. Topics include:
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. |
目次
Introduction | 1 |
What Should You Know Already? | 2 |
What if Im a Perl Course Instructor? | 3 |
Building Larger Programs | 4 |
Inserting Code with eval | 5 |
Using do | 6 |
Using require | 8 |
require and INC | 9 |
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 | |