To address the above discussion really quick - do
HeckIfIKnow->new( ... ) and sidestep the whole problem. Larry himself has said that indirect method calling was a mistake.
To address the OP's question ... there are a few commonly-used classes (Class::MethodMaker and Class::Struct) that I would examine, if I were you. Personally, I found the exercise of creating my own OO-base class to be both fun and edifying.
As for what's wrong ... I can't say this with certainty, but it looks like you're using classes as a way to created HashesThatCanDoStuff. It's still primarily a data structure, just jazzed up. Now, that's fine and all, but it's not OO. OO is three things (q.v. http://c2.com/cgi/wiki?ObjectOriented for more info):
- Encapsulation (You can't poke inside the Foo)
- Inheritance (You can make a Bar that is-a Foo)
- Polymorphism (A method of Foo will do different things depending on the calling context)
While Perl's OO gives you 2 & 3 without you doing anything, HashesThatCanDoStuff don't have Encapsulation. (In fact, pure data-hiding is non-trivial in Perl, but that's another story.)
------
We are the carpenters and bricklayers of the Information Age.
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.