Foreword |
|
xi | |
Preface |
|
xiii | |
|
|
1 | (6) |
|
What Should You Know Already? |
|
|
2 | (1) |
|
|
2 | (1) |
|
|
3 | (1) |
|
|
4 | (1) |
|
What About All Those Footnotes? |
|
|
4 | (1) |
|
What's With the Exercises? |
|
|
4 | (1) |
|
|
5 | (1) |
|
What If I'm a Perl Course Instructor? |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (18) |
|
The Standard Distribution |
|
|
7 | (1) |
|
|
8 | (1) |
|
|
9 | (1) |
|
|
10 | (1) |
|
|
11 | (1) |
|
Object-Oriented Interfaces |
|
|
12 | (1) |
|
A More Typical Object-Oriented Module: Math::BigInt |
|
|
12 | (1) |
|
Fancier Output with Modules |
|
|
13 | (1) |
|
|
14 | (1) |
|
The Comprehensive Perl Archive Network |
|
|
15 | (1) |
|
Installing Modules from CPAN |
|
|
16 | (1) |
|
|
17 | (1) |
|
Installing Modules Manually |
|
|
17 | (1) |
|
Setting the Path at the Right Time |
|
|
18 | (3) |
|
Setting the Path Outside the Program |
|
|
21 | (1) |
|
Extending @INC with PERL5LIB |
|
|
21 | (1) |
|
Extending @INC on the Command Line |
|
|
22 | (1) |
|
|
22 | (1) |
|
|
23 | (2) |
|
3 Intermediate Foundations |
|
|
25 | (10) |
|
|
25 | (1) |
|
|
26 | (2) |
|
Transforming Lists with map |
|
|
28 | (1) |
|
Trapping Errors with eval |
|
|
29 | (2) |
|
|
31 | (1) |
|
|
32 | (1) |
|
|
33 | (2) |
|
4 Introduction to References |
|
|
35 | (18) |
|
Doing the Same Task on Many Arrays |
|
|
35 | (2) |
|
PeGS: Perl Graphical Structures |
|
|
37 | (1) |
|
Taking a Reference to an Array |
|
|
38 | (3) |
|
Dereferencing the Array Reference |
|
|
41 | (1) |
|
|
42 | (1) |
|
|
43 | (1) |
|
|
44 | (1) |
|
Simplifying Nested Element References with Arrows |
|
|
45 | (2) |
|
|
47 | (3) |
|
|
50 | (2) |
|
|
52 | (1) |
|
|
53 | (18) |
|
More than One Reference to Data |
|
|
53 | (1) |
|
What If That Was the Name? |
|
|
54 | (1) |
|
Reference Counting and Nested Data Structures |
|
|
55 | (2) |
|
When Reference Counting Goes Bad |
|
|
57 | (2) |
|
Creating an Anonymous Array Directly |
|
|
59 | (2) |
|
Creating an Anonymous Hash |
|
|
61 | (2) |
|
|
63 | (3) |
|
Autovivification and Hashes |
|
|
66 | (2) |
|
|
68 | (3) |
|
6 Manipulating Complex Data Structures |
|
|
71 | (20) |
|
Using the Debugger to View Complex Data |
|
|
71 | (4) |
|
Viewing Complex Data with Data::Dumper |
|
|
75 | (2) |
|
|
77 | (1) |
|
|
78 | (2) |
|
Storing Complex Data with Storable |
|
|
80 | (5) |
|
|
85 | (1) |
|
|
85 | (1) |
|
Using the map and grep Operators |
|
|
86 | (1) |
|
Applying a Bit of Indirection |
|
|
86 | (2) |
|
Selecting and Altering Complex Data |
|
|
88 | (2) |
|
|
90 | (1) |
|
|
91 | (24) |
|
Referencing a Named Subroutine |
|
|
91 | (5) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
98 | (2) |
|
Returning a Subroutine from a Subroutine |
|
|
100 | (3) |
|
Closure Variables as Inputs |
|
|
103 | (1) |
|
Closure Variables as Static Local Variables |
|
|
104 | (1) |
|
|
105 | (2) |
|
|
107 | (1) |
|
|
108 | (3) |
|
|
111 | (1) |
|
|
112 | (3) |
|
|
115 | (14) |
|
|
115 | (1) |
|
|
116 | (2) |
|
|
118 | (1) |
|
Processing Strings Line by Line |
|
|
119 | (1) |
|
Collections of Filehandles |
|
|
120 | (1) |
|
|
121 | (1) |
|
|
121 | (1) |
|
|
122 | (1) |
|
|
123 | (1) |
|
|
124 | (1) |
|
IO::Null and IO:: Interactive |
|
|
125 | (1) |
|
|
126 | (1) |
|
Directory Handle References |
|
|
126 | (1) |
|
|
127 | (2) |
|
9 Regular Expression References |
|
|
129 | (12) |
|
Before Regular Expression References |
|
|
129 | (2) |
|
|
131 | (1) |
|
Regular Expression Options |
|
|
132 | (1) |
|
Applying Regex References |
|
|
132 | (1) |
|
|
133 | (3) |
|
Build Up Regular Expressions |
|
|
136 | (1) |
|
|
137 | (1) |
|
|
137 | (2) |
|
Assembling Regular Expressions |
|
|
139 | (1) |
|
|
140 | (1) |
|
10 Practical Reference Tricks |
|
|
141 | (18) |
|
|
141 | (2) |
|
|
143 | (1) |
|
|
144 | (1) |
|
The Schwartzian Transform |
|
|
145 | (2) |
|
Multilevel Sort with the Schwartzian Transform |
|
|
147 | (1) |
|
|
147 | (2) |
|
Building Recursively Defined Data |
|
|
149 | (3) |
|
Displaying Recursively Defined Data |
|
|
152 | (1) |
|
|
153 | (1) |
|
The Breadth-First Solution |
|
|
154 | (2) |
|
|
156 | (3) |
|
11 Building Larger Programs |
|
|
159 | (14) |
|
The Cure for the Common Code |
|
|
159 | (1) |
|
|
160 | (1) |
|
|
161 | (2) |
|
|
163 | (1) |
|
The Problem of Namespace Collisions |
|
|
164 | (1) |
|
Packages as Namespace Separators |
|
|
165 | (2) |
|
Scope of a Package Directive |
|
|
167 | (1) |
|
|
168 | (1) |
|
|
169 | (1) |
|
|
170 | (3) |
|
12 Creating Your Own Perl Distribution |
|
|
173 | (18) |
|
|
173 | (1) |
|
|
174 | (1) |
|
|
175 | (1) |
|
|
176 | (1) |
|
|
176 | (1) |
|
|
177 | (1) |
|
|
178 | (1) |
|
Inside Your Perl Distribution |
|
|
178 | (2) |
|
|
180 | (1) |
|
Adding Additional Modules |
|
|
181 | (1) |
|
|
182 | (2) |
|
|
184 | (1) |
|
|
185 | (1) |
|
|
186 | (1) |
|
|
186 | (1) |
|
|
187 | (1) |
|
|
187 | (1) |
|
|
188 | (1) |
|
Creating a Module::Build Distribution |
|
|
188 | (1) |
|
Creating a ExtUtils::Makemaker Distribution |
|
|
189 | (1) |
|
|
189 | (2) |
|
13 Introduction to Objects |
|
|
191 | (14) |
|
If We Could Talk to the Animals... |
|
|
191 | (2) |
|
Introducing the Method Invocation Arrow |
|
|
193 | (1) |
|
The Extra Parameter of Method Invocation |
|
|
194 | (1) |
|
Calling a Second Method to Simplify Things |
|
|
195 | (2) |
|
|
197 | (1) |
|
|
198 | (2) |
|
Starting the Search from a Different Place |
|
|
200 | (1) |
|
The SUPER Way of Doing Things |
|
|
200 | (1) |
|
|
201 | (1) |
|
|
201 | (1) |
|
|
202 | (1) |
|
|
203 | (2) |
|
14 Introduction to Testing |
|
|
205 | (20) |
|
|
205 | (1) |
|
|
206 | (1) |
|
|
206 | (2) |
|
|
208 | (1) |
|
|
209 | (1) |
|
|
210 | (1) |
|
|
211 | (1) |
|
Checking that Modules Compile |
|
|
212 | (1) |
|
|
213 | (3) |
|
|
216 | (1) |
|
|
217 | (3) |
|
Measuring Our Test Coverage |
|
|
220 | (1) |
|
|
221 | (1) |
|
|
221 | (1) |
|
|
221 | (1) |
|
|
222 | (1) |
|
|
222 | (3) |
|
|
225 | (14) |
|
A Horse Is a Horse, of Course of Course---Or Is It? |
|
|
225 | (2) |
|
Invoking an Instance Method |
|
|
227 | (1) |
|
Accessing the Instance Data |
|
|
228 | (1) |
|
|
228 | (1) |
|
Inheriting the Constructor |
|
|
229 | (1) |
|
Making a Method Work with Either Classes or Instances |
|
|
230 | (1) |
|
Adding Parameters to a Method |
|
|
230 | (1) |
|
More Interesting Instances |
|
|
231 | (1) |
|
A Horse of a Different Color |
|
|
232 | (1) |
|
|
233 | (1) |
|
Don't Look Inside the Box |
|
|
234 | (1) |
|
Faster Getters and Setters |
|
|
235 | (1) |
|
Getters that Double as Setters |
|
|
236 | (1) |
|
Restricting a Method to Class Only or Instance Only |
|
|
236 | (1) |
|
|
237 | (2) |
|
16 Some Advanced Object Topics |
|
|
239 | (10) |
|
|
239 | (1) |
|
Testing Our Objects for Good Behavior |
|
|
240 | (2) |
|
|
242 | (1) |
|
Using AUTOLOAD for Accessors |
|
|
243 | (1) |
|
Creating Getters and Setters More Easily |
|
|
244 | (2) |
|
|
246 | (1) |
|
|
247 | (2) |
|
|
249 | (8) |
|
|
249 | (1) |
|
|
250 | (1) |
|
|
251 | (1) |
|
Grouping with %EXPORT_TAGS |
|
|
252 | (2) |
|
|
254 | (2) |
|
|
256 | (1) |
|
|
257 | (16) |
|
Cleaning Up After Ourselves |
|
|
257 | (2) |
|
Nested Object Destruction |
|
|
259 | (3) |
|
|
262 | (1) |
|
|
263 | (2) |
|
Additional Instance Variables in Subclasses |
|
|
265 | (2) |
|
|
267 | (1) |
|
|
268 | (2) |
|
|
270 | (3) |
|
|
273 | (12) |
|
Making Animals with Moose |
|
|
273 | (3) |
|
Roles Instead of Inheritance |
|
|
276 | (1) |
|
|
277 | (1) |
|
|
278 | (1) |
|
|
279 | (2) |
|
|
281 | (1) |
|
|
281 | (2) |
|
|
283 | (1) |
|
|
283 | (2) |
|
|
285 | (14) |
|
|
285 | (1) |
|
Testing Object-Oriented Features |
|
|
286 | (1) |
|
|
287 | (1) |
|
|
288 | (1) |
|
|
289 | (1) |
|
|
290 | (3) |
|
|
293 | (1) |
|
Writing Our Own Test::* Modules |
|
|
294 | (3) |
|
|
297 | (2) |
|
|
299 | (12) |
|
The Comprehensive Perl Archive Network |
|
|
299 | (1) |
|
|
299 | (1) |
|
|
300 | (1) |
|
|
301 | (1) |
|
|
302 | (1) |
|
|
303 | (1) |
|
Preparing the Distribution |
|
|
303 | (1) |
|
Create or Update the README |
|
|
304 | (1) |
|
|
304 | (1) |
|
|
304 | (2) |
|
Increase the Version String |
|
|
306 | (1) |
|
|
306 | (1) |
|
Uploading the Distribution |
|
|
307 | (1) |
|
Testing on Multiple Platforms |
|
|
307 | (1) |
|
|
308 | (1) |
|
|
308 | (3) |
Appendix: Answers to Exercises |
|
311 | (48) |
Index of Modules in this Book |
|
359 | (4) |
Index |
|
363 | |