> 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!


In reply to Re^5: OOP and derived classes by LanX
in thread OOP and derived classes by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.