in reply to Stuck on packages
Secondly, if you want to display the attributes of a class instance you need to call the methods of that instance. Your three example classes don't have any methods, and print($car) just prints a stringified version of the $car object, which is the type of variable $car represents followed by its location in memory. To get the behavior you want you should do something like $car->print where "print" represents a method in the Family package that calls "getter" methods for each attribute you want to display.
I would strongly recommend Damian Conway's Object Oriented Perl if you want to learn (most) all there is to know about Perl 5 OO programming.
Gary Blackburn
Trained Killer
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Stuck on packages
by Yoda_Oz (Sexton) on Jan 04, 2007 at 04:46 UTC | |
by duckyd (Hermit) on Jan 04, 2007 at 06:25 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 06:43 UTC | |
by SheridanCat (Pilgrim) on Jan 04, 2007 at 07:16 UTC | |
by Yoda_Oz (Sexton) on Jan 04, 2007 at 07:21 UTC | |
| |
by SheridanCat (Pilgrim) on Jan 04, 2007 at 07:22 UTC | |
|