Esteemed Monks,

I am rapidly learning about Perl's Object Oriented features. Right now I want to write a module that has some 'common methods' that I would like to be able to inherit in other modules. For example:

I have a Tk based programme. In it I have created whole sections of the UI as objects and this has worked well. But I now find that some parts of these various UI's are common to each other, particularly things like listcmd and browsecmd methods for BrowseEntry's for example.

How do I handle this?

Do I put the methods in a module called, say "handy_methods" and inherit it using @ISA = qw( handy_methods );?

Then I assume that once 'inherited' that the methods have access to the attributes of the blessed hash? So that I can directly refer to attributes rather than having to pass references into the method.

I am reading chapter 6 of thedamian's book on Object Oriented Perl but I am getting a little lost in here!

jdtoronto


In reply to Help me understand inheritance please! by jdtoronto

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.