ADBRITE ads links
You are here: CodeIdol.com > Perl > Intermediate Perl > Object Destruction
Intermediate Perl
| 13.1. Cleaning Up After Yourself
Suppose our object uses a temporary file to hold data that won't fit entirely in memory. The object can include the filehandle for this temporary file in its instance data. While the normal obj...
|
|
| 13.2. Nested Object Destruction
If an object holds another object (say, as an element of an array or the value of a hash element), Perl DESTROYs the containing object before any of the contained objects begin their discarding process. Thi...
|
|
| 13.3. Beating a Dead Horse
Because the destructor method is inherited, we can also override and extend superclass methods. For example, we'll decide the dead horses need a further use. In our Horse class, we override the DE...
|
|
| 13.4. Indirect Object Notation
The arrow syntax used to invoke a method is sometimes called the direct object syntax because there's also the indirect object syntax, also known as the "only works sometimes" syntax, for reasons we ex...
|
|
| 13.5. Additional Instance Variables in Subclasses
One of the nice things about using a hash for a data structure is that derived classes can add additional instance variables without the superclass needing to know of their addition. Fo...
|
|
| 13.6. Using Class Variables
What if we want to iterate over all the animals we've made so far? Animals may exist all over the program namespace but are lost once they're handed back from the named constructor method.[*][*] Well, not reall...
|
|
| 13.7. Weakening the Argument
The %REGISTRY variable also holds a reference to each animal. So even if we toss away the containing variables, for instance by letting them go out of scope:
{
my @cows = map Cow->named($_), qw(Bessie Gwen)...
|
|
| 13.8. Exercise
You can find the answer to this exercise in "Answer for Chapter 13" in the Appendix.
13.8.1. Exercise [45 min]
Modify the RaceHorse class to get the previous standings from a DBM hash (keyed by the horse's name) when the horse i...
|
|
You are here: CodeIdol.com > Perl > Intermediate Perl > Object Destruction
|
|
Related tags
Popular Categories
Unix books and guides
AJAX popular information
C# language guides
Windows books and cookbooks
.......
|
|