in reply to Point me in the right direction with OO inheritance and static variables
I'm not sure where to begin with inheritance though. I was hoping someone could point me in the right direction?A package in Perl can have a magic array @ISA. This array can hold strings, which must be names of packages (class and package is the same thing). When you call a method on an object, like $some_object->some_method() Perl checks which class (package) this $some_object belongs to (you specified it with function bless). If that class doesn't have some_method, then Perl checks the @ISA array of the class. It takes the first string from this array, assumes it's a package name and then searches that package for some_method. If some_method is found, Perl calls some_method, with $some_object as the first argument. So, $some_object->some_method() is equivalent to SomeClass::some_method($some_object) (SomeClass comes from an @ISA array). And that is OOP in Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Point me in the right direction with OO inheritance and static variables
by choroba (Cardinal) on Sep 02, 2014 at 11:36 UTC | |
by tobyink (Canon) on Sep 02, 2014 at 19:51 UTC |