in reply to Re^4: OOP and derived classes
in thread OOP and derived classes

> but do the other more simple modules follow this model of instantiating the base class, inside their constructor?

yes!

An object $obj in Perl is just a reference (to a data container, normally hashes) combined with a pointer to a package (read class). This coupling is done with bless and is also dynamic.

Any method-call on an object like $obj->meth(args...) looks for a sub called meth in the blessed package or otherwise in its inheritance chain (see @ISA )

When meth() is found it gets called with meth($obj,args...) and by convention the first parameter has to be stored into a variable called $self .

Any method can be a constructor (i.e. putting data into a structure and returning the blessed reference), calling it by Class->new() is just another convention (in this case the first argument will be the string "Class" normally put into something like $pckg ). You can even have multiple constructors.

That's basically all you need to know!

It seems very raw and rudimentary at the beginning but after understanding it you can model most other object models.

Cheers Rolf

PS: Je suis Charlie!