Just another Perl shrine | |
PerlMonks |
A Not-as-Clumsy OOP Implementation?by billyak (Friar) |
on Aug 25, 2001 at 17:29 UTC ( [id://107818]=perlquestion: print w/replies, xml ) | Need Help?? |
billyak has asked for the wisdom of the Perl Monks concerning the following question:
I've been working on a project that has recently turned into something I'd like to attempt to convert to OOP. I've messed with OOP in the past, but most I've put together in an attempt at it were pretty wretched. In the past I've tried to work things out on my own, but I've spent far too long writing bad code. I turn to my fellow monks for assistance.
Here is the general idea and the implementation (or my excuse of one).
Monitor port ### Thats the goal. So here is the clencher. I want it to be a somewhat modular system for adding new events (at the **'s part.) Right now I've got a Monitor package that I would like to have run things, and a Function package to hold all of the "functions" (the ** code.) Here is some relevant code (constructors and other vital code omitted): Then I would get packets, loop through the $FUNC keys, applying the regexes and sending the data to the appropriate subs when the regex was a match. For some reason, I think there is a much better way to do this. The name space is also really messy. Ideally, I'd want several hashes and a few object refs to be globally accessible across packages; no doubt that is an obvious sign of bad code. Hopefully I have done an adequate job at showing what I am trying to achieve. I would really appreciate any suggestions or comments anyone could contribute. Thanks. -billyak
Back to
Seekers of Perl Wisdom
|
|