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,
ChrisIn reply to Generic Composite Interface by chhe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |