1PERLBOOT(1)            Perl Programmers Reference Guide            PERLBOOT(1)
2
3
4

NAME

6       perlboot - Beginner's Object-Oriented Tutorial
7

DESCRIPTION

9       If you're not familiar with objects from other languages, some of the
10       other Perl object documentation may be a little daunting, such as per‐
11       lobj, a basic reference in using objects, and perltoot, which intro‐
12       duces readers to the peculiarities of Perl's object system in a tuto‐
13       rial way.
14
15       So, let's take a different approach, presuming no prior object experi‐
16       ence. It helps if you know about subroutines (perlsub), references
17       (perlref et. seq.), and packages (perlmod), so become familiar with
18       those first if you haven't already.
19
20       If we could talk to the animals...
21
22       Let's let the animals talk for a moment:
23
24           sub Cow::speak {
25             print "a Cow goes moooo!\n";
26           }
27           sub Horse::speak {
28             print "a Horse goes neigh!\n";
29           }
30           sub Sheep::speak {
31             print "a Sheep goes baaaah!\n"
32           }
33
34           Cow::speak;
35           Horse::speak;
36           Sheep::speak;
37
38       This results in:
39
40           a Cow goes moooo!
41           a Horse goes neigh!
42           a Sheep goes baaaah!
43
44       Nothing spectacular here.  Simple subroutines, albeit from separate
45       packages, and called using the full package name.  So let's create an
46       entire pasture:
47
48           # Cow::speak, Horse::speak, Sheep::speak as before
49           @pasture = qw(Cow Cow Horse Sheep Sheep);
50           foreach $animal (@pasture) {
51             &{$animal."::speak"};
52           }
53
54       This results in:
55
56           a Cow goes moooo!
57           a Cow goes moooo!
58           a Horse goes neigh!
59           a Sheep goes baaaah!
60           a Sheep goes baaaah!
61
62       Wow.  That symbolic coderef de-referencing there is pretty nasty.
63       We're counting on "no strict subs" mode, certainly not recommended for
64       larger programs.  And why was that necessary?  Because the name of the
65       package seems to be inseparable from the name of the subroutine we want
66       to invoke within that package.
67
68       Or is it?
69
70       Introducing the method invocation arrow
71
72       For now, let's say that "Class->method" invokes subroutine "method" in
73       package "Class".  (Here, "Class" is used in its "category" meaning, not
74       its "scholastic" meaning.) That's not completely accurate, but we'll do
75       this one step at a time.  Now let's use it like so:
76
77           # Cow::speak, Horse::speak, Sheep::speak as before
78           Cow->speak;
79           Horse->speak;
80           Sheep->speak;
81
82       And once again, this results in:
83
84           a Cow goes moooo!
85           a Horse goes neigh!
86           a Sheep goes baaaah!
87
88       That's not fun yet.  Same number of characters, all constant, no vari‐
89       ables.  But yet, the parts are separable now.  Watch:
90
91           $a = "Cow";
92           $a->speak; # invokes Cow->speak
93
94       Ahh!  Now that the package name has been parted from the subroutine
95       name, we can use a variable package name.  And this time, we've got
96       something that works even when "use strict refs" is enabled.
97
98       Invoking a barnyard
99
100       Let's take that new arrow invocation and put it back in the barnyard
101       example:
102
103           sub Cow::speak {
104             print "a Cow goes moooo!\n";
105           }
106           sub Horse::speak {
107             print "a Horse goes neigh!\n";
108           }
109           sub Sheep::speak {
110             print "a Sheep goes baaaah!\n"
111           }
112
113           @pasture = qw(Cow Cow Horse Sheep Sheep);
114           foreach $animal (@pasture) {
115             $animal->speak;
116           }
117
118       There!  Now we have the animals all talking, and safely at that, with‐
119       out the use of symbolic coderefs.
120
121       But look at all that common code.  Each of the "speak" routines has a
122       similar structure: a "print" operator and a string that contains common
123       text, except for two of the words.  It'd be nice if we could factor out
124       the commonality, in case we decide later to change it all to "says"
125       instead of "goes".
126
127       And we actually have a way of doing that without much fuss, but we have
128       to hear a bit more about what the method invocation arrow is actually
129       doing for us.
130
131       The extra parameter of method invocation
132
133       The invocation of:
134
135           Class->method(@args)
136
137       attempts to invoke subroutine "Class::method" as:
138
139           Class::method("Class", @args);
140
141       (If the subroutine can't be found, "inheritance" kicks in, but we'll
142       get to that later.)  This means that we get the class name as the first
143       parameter (the only parameter, if no arguments are given).  So we can
144       rewrite the "Sheep" speaking subroutine as:
145
146           sub Sheep::speak {
147             my $class = shift;
148             print "a $class goes baaaah!\n";
149           }
150
151       And the other two animals come out similarly:
152
153           sub Cow::speak {
154             my $class = shift;
155             print "a $class goes moooo!\n";
156           }
157           sub Horse::speak {
158             my $class = shift;
159             print "a $class goes neigh!\n";
160           }
161
162       In each case, $class will get the value appropriate for that subrou‐
163       tine.  But once again, we have a lot of similar structure.  Can we fac‐
164       tor that out even further?  Yes, by calling another method in the same
165       class.
166
167       Calling a second method to simplify things
168
169       Let's call out from "speak" to a helper method called "sound".  This
170       method provides the constant text for the sound itself.
171
172           { package Cow;
173             sub sound { "moooo" }
174             sub speak {
175               my $class = shift;
176               print "a $class goes ", $class->sound, "!\n"
177             }
178           }
179
180       Now, when we call "Cow->speak", we get a $class of "Cow" in "speak".
181       This in turn selects the "Cow->sound" method, which returns "moooo".
182       But how different would this be for the "Horse"?
183
184           { package Horse;
185             sub sound { "neigh" }
186             sub speak {
187               my $class = shift;
188               print "a $class goes ", $class->sound, "!\n"
189             }
190           }
191
192       Only the name of the package and the specific sound change.  So can we
193       somehow share the definition for "speak" between the Cow and the Horse?
194       Yes, with inheritance!
195
196       Inheriting the windpipes
197
198       We'll define a common subroutine package called "Animal", with the def‐
199       inition for "speak":
200
201           { package Animal;
202             sub speak {
203               my $class = shift;
204               print "a $class goes ", $class->sound, "!\n"
205             }
206           }
207
208       Then, for each animal, we say it "inherits" from "Animal", along with
209       the animal-specific sound:
210
211           { package Cow;
212             @ISA = qw(Animal);
213             sub sound { "moooo" }
214           }
215
216       Note the added @ISA array.  We'll get to that in a minute.
217
218       But what happens when we invoke "Cow->speak" now?
219
220       First, Perl constructs the argument list.  In this case, it's just
221       "Cow".  Then Perl looks for "Cow::speak".  But that's not there, so
222       Perl checks for the inheritance array @Cow::ISA.  It's there, and con‐
223       tains the single name "Animal".
224
225       Perl next checks for "speak" inside "Animal" instead, as in "Ani‐
226       mal::speak".  And that's found, so Perl invokes that subroutine with
227       the already frozen argument list.
228
229       Inside the "Animal::speak" subroutine, $class becomes "Cow" (the first
230       argument).  So when we get to the step of invoking "$class->sound",
231       it'll be looking for "Cow->sound", which gets it on the first try with‐
232       out looking at @ISA.  Success!
233
234       A few notes about @ISA
235
236       This magical @ISA variable (pronounced "is a" not "ice-uh"), has
237       declared that "Cow" "is a" "Animal".  Note that it's an array, not a
238       simple single value, because on rare occasions, it makes sense to have
239       more than one parent class searched for the missing methods.
240
241       If "Animal" also had an @ISA, then we'd check there too.  The search is
242       recursive, depth-first, left-to-right in each @ISA.  Typically, each
243       @ISA has only one element (multiple elements means multiple inheritance
244       and multiple headaches), so we get a nice tree of inheritance.
245
246       When we turn on "use strict", we'll get complaints on @ISA, since it's
247       not a variable containing an explicit package name, nor is it a lexical
248       ("my") variable.  We can't make it a lexical variable though (it has to
249       belong to the package to be found by the inheritance mechanism), so
250       there's a couple of straightforward ways to handle that.
251
252       The easiest is to just spell the package name out:
253
254           @Cow::ISA = qw(Animal);
255
256       Or allow it as an implicitly named package variable:
257
258           package Cow;
259           use vars qw(@ISA);
260           @ISA = qw(Animal);
261
262       If you're bringing in the class from outside, via an object-oriented
263       module, you change:
264
265           package Cow;
266           use Animal;
267           use vars qw(@ISA);
268           @ISA = qw(Animal);
269
270       into just:
271
272           package Cow;
273           use base qw(Animal);
274
275       And that's pretty darn compact.
276
277       Overriding the methods
278
279       Let's add a mouse, which can barely be heard:
280
281           # Animal package from before
282           { package Mouse;
283             @ISA = qw(Animal);
284             sub sound { "squeak" }
285             sub speak {
286               my $class = shift;
287               print "a $class goes ", $class->sound, "!\n";
288               print "[but you can barely hear it!]\n";
289             }
290           }
291
292           Mouse->speak;
293
294       which results in:
295
296           a Mouse goes squeak!
297           [but you can barely hear it!]
298
299       Here, "Mouse" has its own speaking routine, so "Mouse->speak" doesn't
300       immediately invoke "Animal->speak".  This is known as "overriding".  In
301       fact, we didn't even need to say that a "Mouse" was an "Animal" at all,
302       since all of the methods needed for "speak" are completely defined with
303       "Mouse".
304
305       But we've now duplicated some of the code from "Animal->speak", and
306       this can once again be a maintenance headache.  So, can we avoid that?
307       Can we say somehow that a "Mouse" does everything any other "Animal"
308       does, but add in the extra comment?  Sure!
309
310       First, we can invoke the "Animal::speak" method directly:
311
312           # Animal package from before
313           { package Mouse;
314             @ISA = qw(Animal);
315             sub sound { "squeak" }
316             sub speak {
317               my $class = shift;
318               Animal::speak($class);
319               print "[but you can barely hear it!]\n";
320             }
321           }
322
323       Note that we have to include the $class parameter (almost surely the
324       value of "Mouse") as the first parameter to "Animal::speak", since
325       we've stopped using the method arrow.  Why did we stop?  Well, if we
326       invoke "Animal->speak" there, the first parameter to the method will be
327       "Animal" not "Mouse", and when time comes for it to call for the
328       "sound", it won't have the right class to come back to this package.
329
330       Invoking "Animal::speak" directly is a mess, however.  What if "Ani‐
331       mal::speak" didn't exist before, and was being inherited from a class
332       mentioned in @Animal::ISA?  Because we are no longer using the method
333       arrow, we get one and only one chance to hit the right subroutine.
334
335       Also note that the "Animal" classname is now hardwired into the subrou‐
336       tine selection.  This is a mess if someone maintains the code, changing
337       @ISA for <Mouse> and didn't notice "Animal" there in "speak".  So, this
338       is probably not the right way to go.
339
340       Starting the search from a different place
341
342       A better solution is to tell Perl to search from a higher place in the
343       inheritance chain:
344
345           # same Animal as before
346           { package Mouse;
347             # same @ISA, &sound as before
348             sub speak {
349               my $class = shift;
350               $class->Animal::speak;
351               print "[but you can barely hear it!]\n";
352             }
353           }
354
355       Ahh.  This works.  Using this syntax, we start with "Animal" to find
356       "speak", and use all of "Animal"'s inheritance chain if not found imme‐
357       diately.  And yet the first parameter will be $class, so the found
358       "speak" method will get "Mouse" as its first entry, and eventually work
359       its way back to "Mouse::sound" for the details.
360
361       But this isn't the best solution.  We still have to keep the @ISA and
362       the initial search package coordinated.  Worse, if "Mouse" had multiple
363       entries in @ISA, we wouldn't necessarily know which one had actually
364       defined "speak".  So, is there an even better way?
365
366       The SUPER way of doing things
367
368       By changing the "Animal" class to the "SUPER" class in that invocation,
369       we get a search of all of our super classes (classes listed in @ISA)
370       automatically:
371
372           # same Animal as before
373           { package Mouse;
374             # same @ISA, &sound as before
375             sub speak {
376               my $class = shift;
377               $class->SUPER::speak;
378               print "[but you can barely hear it!]\n";
379             }
380           }
381
382       So, "SUPER::speak" means look in the current package's @ISA for
383       "speak", invoking the first one found. Note that it does not look in
384       the @ISA of $class.
385
386       Where we're at so far...
387
388       So far, we've seen the method arrow syntax:
389
390         Class->method(@args);
391
392       or the equivalent:
393
394         $a = "Class";
395         $a->method(@args);
396
397       which constructs an argument list of:
398
399         ("Class", @args)
400
401       and attempts to invoke
402
403         Class::method("Class", @Args);
404
405       However, if "Class::method" is not found, then @Class::ISA is examined
406       (recursively) to locate a package that does indeed contain "method",
407       and that subroutine is invoked instead.
408
409       Using this simple syntax, we have class methods, (multiple) inheri‐
410       tance, overriding, and extending.  Using just what we've seen so far,
411       we've been able to factor out common code, and provide a nice way to
412       reuse implementations with variations.  This is at the core of what
413       objects provide, but objects also provide instance data, which we
414       haven't even begun to cover.
415
416       A horse is a horse, of course of course -- or is it?
417
418       Let's start with the code for the "Animal" class and the "Horse" class:
419
420         { package Animal;
421           sub speak {
422             my $class = shift;
423             print "a $class goes ", $class->sound, "!\n"
424           }
425         }
426         { package Horse;
427           @ISA = qw(Animal);
428           sub sound { "neigh" }
429         }
430
431       This lets us invoke "Horse->speak" to ripple upward to "Animal::speak",
432       calling back to "Horse::sound" to get the specific sound, and the out‐
433       put of:
434
435         a Horse goes neigh!
436
437       But all of our Horse objects would have to be absolutely identical.  If
438       I add a subroutine, all horses automatically share it.  That's great
439       for making horses the same, but how do we capture the distinctions
440       about an individual horse?  For example, suppose I want to give my
441       first horse a name.  There's got to be a way to keep its name separate
442       from the other horses.
443
444       We can do that by drawing a new distinction, called an "instance".  An
445       "instance" is generally created by a class.  In Perl, any reference can
446       be an instance, so let's start with the simplest reference that can
447       hold a horse's name: a scalar reference.
448
449         my $name = "Mr. Ed";
450         my $talking = \$name;
451
452       So now $talking is a reference to what will be the instance-specific
453       data (the name).  The final step in turning this into a real instance
454       is with a special operator called "bless":
455
456         bless $talking, Horse;
457
458       This operator stores information about the package named "Horse" into
459       the thing pointed at by the reference.  At this point, we say $talking
460       is an instance of "Horse".  That is, it's a specific horse.  The refer‐
461       ence is otherwise unchanged, and can still be used with traditional
462       dereferencing operators.
463
464       Invoking an instance method
465
466       The method arrow can be used on instances, as well as names of packages
467       (classes).  So, let's get the sound that $talking makes:
468
469         my $noise = $talking->sound;
470
471       To invoke "sound", Perl first notes that $talking is a blessed refer‐
472       ence (and thus an instance).  It then constructs an argument list, in
473       this case from just "($talking)".  (Later we'll see that arguments will
474       take their place following the instance variable, just like with
475       classes.)
476
477       Now for the fun part: Perl takes the class in which the instance was
478       blessed, in this case "Horse", and uses that to locate the subroutine
479       to invoke the method.  In this case, "Horse::sound" is found directly
480       (without using inheritance), yielding the final subroutine invocation:
481
482         Horse::sound($talking)
483
484       Note that the first parameter here is still the instance, not the name
485       of the class as before.  We'll get "neigh" as the return value, and
486       that'll end up as the $noise variable above.
487
488       If Horse::sound had not been found, we'd be wandering up the
489       @Horse::ISA list to try to find the method in one of the superclasses,
490       just as for a class method.  The only difference between a class method
491       and an instance method is whether the first parameter is an instance (a
492       blessed reference) or a class name (a string).
493
494       Accessing the instance data
495
496       Because we get the instance as the first parameter, we can now access
497       the instance-specific data.  In this case, let's add a way to get at
498       the name:
499
500         { package Horse;
501           @ISA = qw(Animal);
502           sub sound { "neigh" }
503           sub name {
504             my $self = shift;
505             $$self;
506           }
507         }
508
509       Now we call for the name:
510
511         print $talking->name, " says ", $talking->sound, "\n";
512
513       Inside "Horse::name", the @_ array contains just $talking, which the
514       "shift" stores into $self.  (It's traditional to shift the first param‐
515       eter off into a variable named $self for instance methods, so stay with
516       that unless you have strong reasons otherwise.)  Then, $self gets de-
517       referenced as a scalar ref, yielding "Mr. Ed", and we're done with
518       that.  The result is:
519
520         Mr. Ed says neigh.
521
522       How to build a horse
523
524       Of course, if we constructed all of our horses by hand, we'd most
525       likely make mistakes from time to time.  We're also violating one of
526       the properties of object-oriented programming, in that the "inside
527       guts" of a Horse are visible.  That's good if you're a veterinarian,
528       but not if you just like to own horses.  So, let's let the Horse class
529       build a new horse:
530
531         { package Horse;
532           @ISA = qw(Animal);
533           sub sound { "neigh" }
534           sub name {
535             my $self = shift;
536             $$self;
537           }
538           sub named {
539             my $class = shift;
540             my $name = shift;
541             bless \$name, $class;
542           }
543         }
544
545       Now with the new "named" method, we can build a horse:
546
547         my $talking = Horse->named("Mr. Ed");
548
549       Notice we're back to a class method, so the two arguments to
550       "Horse::named" are "Horse" and "Mr. Ed".  The "bless" operator not only
551       blesses $name, it also returns the reference to $name, so that's fine
552       as a return value.  And that's how to build a horse.
553
554       We've called the constructor "named" here, so that it quickly denotes
555       the constructor's argument as the name for this particular "Horse".
556       You can use different constructors with different names for different
557       ways of "giving birth" to the object (like maybe recording its pedigree
558       or date of birth).  However, you'll find that most people coming to
559       Perl from more limited languages use a single constructor named "new",
560       with various ways of interpreting the arguments to "new".  Either style
561       is fine, as long as you document your particular way of giving birth to
562       an object.  (And you were going to do that, right?)
563
564       Inheriting the constructor
565
566       But was there anything specific to "Horse" in that method?  No.  There‐
567       fore, it's also the same recipe for building anything else that inher‐
568       ited from "Animal", so let's put it there:
569
570         { package Animal;
571           sub speak {
572             my $class = shift;
573             print "a $class goes ", $class->sound, "!\n"
574           }
575           sub name {
576             my $self = shift;
577             $$self;
578           }
579           sub named {
580             my $class = shift;
581             my $name = shift;
582             bless \$name, $class;
583           }
584         }
585         { package Horse;
586           @ISA = qw(Animal);
587           sub sound { "neigh" }
588         }
589
590       Ahh, but what happens if we invoke "speak" on an instance?
591
592         my $talking = Horse->named("Mr. Ed");
593         $talking->speak;
594
595       We get a debugging value:
596
597         a Horse=SCALAR(0xaca42ac) goes neigh!
598
599       Why?  Because the "Animal::speak" routine is expecting a classname as
600       its first parameter, not an instance.  When the instance is passed in,
601       we'll end up using a blessed scalar reference as a string, and that
602       shows up as we saw it just now.
603
604       Making a method work with either classes or instances
605
606       All we need is for a method to detect if it is being called on a class
607       or called on an instance.  The most straightforward way is with the
608       "ref" operator.  This returns a string (the classname) when used on a
609       blessed reference, and "undef" when used on a string (like a class‐
610       name).  Let's modify the "name" method first to notice the change:
611
612         sub name {
613           my $either = shift;
614           ref $either
615             ? $$either # it's an instance, return name
616             : "an unnamed $either"; # it's a class, return generic
617         }
618
619       Here, the "?:" operator comes in handy to select either the dereference
620       or a derived string.  Now we can use this with either an instance or a
621       class.  Note that I've changed the first parameter holder to $either to
622       show that this is intended:
623
624         my $talking = Horse->named("Mr. Ed");
625         print Horse->name, "\n"; # prints "an unnamed Horse\n"
626         print $talking->name, "\n"; # prints "Mr Ed.\n"
627
628       and now we'll fix "speak" to use this:
629
630         sub speak {
631           my $either = shift;
632           print $either->name, " goes ", $either->sound, "\n";
633         }
634
635       And since "sound" already worked with either a class or an instance,
636       we're done!
637
638       Adding parameters to a method
639
640       Let's train our animals to eat:
641
642         { package Animal;
643           sub named {
644             my $class = shift;
645             my $name = shift;
646             bless \$name, $class;
647           }
648           sub name {
649             my $either = shift;
650             ref $either
651               ? $$either # it's an instance, return name
652               : "an unnamed $either"; # it's a class, return generic
653           }
654           sub speak {
655             my $either = shift;
656             print $either->name, " goes ", $either->sound, "\n";
657           }
658           sub eat {
659             my $either = shift;
660             my $food = shift;
661             print $either->name, " eats $food.\n";
662           }
663         }
664         { package Horse;
665           @ISA = qw(Animal);
666           sub sound { "neigh" }
667         }
668         { package Sheep;
669           @ISA = qw(Animal);
670           sub sound { "baaaah" }
671         }
672
673       And now try it out:
674
675         my $talking = Horse->named("Mr. Ed");
676         $talking->eat("hay");
677         Sheep->eat("grass");
678
679       which prints:
680
681         Mr. Ed eats hay.
682         an unnamed Sheep eats grass.
683
684       An instance method with parameters gets invoked with the instance, and
685       then the list of parameters.  So that first invocation is like:
686
687         Animal::eat($talking, "hay");
688
689       More interesting instances
690
691       What if an instance needs more data?  Most interesting instances are
692       made of many items, each of which can in turn be a reference or even
693       another object.  The easiest way to store these is often in a hash.
694       The keys of the hash serve as the names of parts of the object (often
695       called "instance variables" or "member variables"), and the correspond‐
696       ing values are, well, the values.
697
698       But how do we turn the horse into a hash?  Recall that an object was
699       any blessed reference.  We can just as easily make it a blessed hash
700       reference as a blessed scalar reference, as long as everything that
701       looks at the reference is changed accordingly.
702
703       Let's make a sheep that has a name and a color:
704
705         my $bad = bless { Name => "Evil", Color => "black" }, Sheep;
706
707       so "$bad->{Name}" has "Evil", and "$bad->{Color}" has "black".  But we
708       want to make "$bad->name" access the name, and that's now messed up
709       because it's expecting a scalar reference.  Not to worry, because
710       that's pretty easy to fix up:
711
712         ## in Animal
713         sub name {
714           my $either = shift;
715           ref $either ?
716             $either->{Name} :
717             "an unnamed $either";
718         }
719
720       And of course "named" still builds a scalar sheep, so let's fix that as
721       well:
722
723         ## in Animal
724         sub named {
725           my $class = shift;
726           my $name = shift;
727           my $self = { Name => $name, Color => $class->default_color };
728           bless $self, $class;
729         }
730
731       What's this "default_color"?  Well, if "named" has only the name, we
732       still need to set a color, so we'll have a class-specific initial
733       color.  For a sheep, we might define it as white:
734
735         ## in Sheep
736         sub default_color { "white" }
737
738       And then to keep from having to define one for each additional class,
739       we'll define a "backstop" method that serves as the "default default",
740       directly in "Animal":
741
742         ## in Animal
743         sub default_color { "brown" }
744
745       Now, because "name" and "named" were the only methods that referenced
746       the "structure" of the object, the rest of the methods can remain the
747       same, so "speak" still works as before.
748
749       A horse of a different color
750
751       But having all our horses be brown would be boring.  So let's add a
752       method or two to get and set the color.
753
754         ## in Animal
755         sub color {
756           $_[0]->{Color}
757         }
758         sub set_color {
759           $_[0]->{Color} = $_[1];
760         }
761
762       Note the alternate way of accessing the arguments: $_[0] is used
763       in-place, rather than with a "shift".  (This saves us a bit of time for
764       something that may be invoked frequently.)  And now we can fix that
765       color for Mr. Ed:
766
767         my $talking = Horse->named("Mr. Ed");
768         $talking->set_color("black-and-white");
769         print $talking->name, " is colored ", $talking->color, "\n";
770
771       which results in:
772
773         Mr. Ed is colored black-and-white
774
775       Summary
776
777       So, now we have class methods, constructors, instance methods, instance
778       data, and even accessors.  But that's still just the beginning of what
779       Perl has to offer.  We haven't even begun to talk about accessors that
780       double as getters and setters, destructors, indirect object notation,
781       subclasses that add instance data, per-class data, overloading, "isa"
782       and "can" tests, "UNIVERSAL" class, and so on.  That's for the rest of
783       the Perl documentation to cover.  Hopefully, this gets you started,
784       though.
785

SEE ALSO

787       For more information, see perlobj (for all the gritty details about
788       Perl objects, now that you've seen the basics), perltoot (the tutorial
789       for those who already know objects), perltooc (dealing with class
790       data), perlbot (for some more tricks), and books such as Damian Con‐
791       way's excellent Object Oriented Perl.
792
793       Some modules which might prove interesting are Class::Accessor,
794       Class::Class, Class::Contract, Class::Data::Inheritable, Class::Method‐
795       Maker and Tie::SecureHash
796
798       Copyright (c) 1999, 2000 by Randal L. Schwartz and Stonehenge Consult‐
799       ing Services, Inc.  Permission is hereby granted to distribute this
800       document intact with the Perl distribution, and in accordance with the
801       licenses of the Perl distribution; derived documents must include this
802       copyright notice intact.
803
804       Portions of this text have been derived from Perl Training materials
805       originally appearing in the Packages, References, Objects, and Modules
806       course taught by instructors for Stonehenge Consulting Services, Inc.
807       and used with permission.
808
809       Portions of this text have been derived from materials originally
810       appearing in Linux Magazine and used with permission.
811
812
813
814perl v5.8.8                       2006-01-07                       PERLBOOT(1)
Impressum