chhe has asked for the wisdom of the Perl Monks concerning the following question:
i have implemented the composite pattern of the gang of four fame with perl.
Basically i have a perl module, which loads and instanciates perl objects and puts them into a hash.
And i have a function, which iterates through the hash and calls the same function of the perl objects in the hash, something like this:
sub log { my $self = shift; my $sender = shift; my $message = shift; my $logger = undef; foreach $logger ($self->loggers()) { $logger->log($sender, $message); } }
Everthing fine so fare, except a little disturbing thing, that for each new modul i want to use through the composite interface i include a new use statement.
Surely not the most elegant way to add new functionality.
So humbly i ask the Perl Monks if there isn't a more wiser way to do this, to avoid this clumsy addition of a "use" statement for each new Module.
Yours, a humble seeker of Perl wisdom,
Chris
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Generic Composite Interface
by jeffa (Bishop) on Mar 23, 2002 at 16:45 UTC | |
by chhe (Sexton) on Mar 23, 2002 at 19:40 UTC | |
by jeffa (Bishop) on Mar 23, 2002 at 19:52 UTC | |
|
•Re: Generic Composite Interface
by merlyn (Sage) on Mar 23, 2002 at 16:09 UTC | |
by chhe (Sexton) on Mar 23, 2002 at 19:30 UTC | |
by merlyn (Sage) on Mar 23, 2002 at 20:24 UTC | |
by chhe (Sexton) on Mar 24, 2002 at 17:41 UTC | |
by merlyn (Sage) on Mar 24, 2002 at 17:45 UTC | |
|