in reply to Dynamically load unknown modules
Code review invited (yes i'm going to change the name of "superclass").. :-)
sub post_configure_hook { my $self = shift; $self->logObj( Logger->new(name => 'log/gaa') ); $self->xml( new XML::Simple(xmldecl => 1,forcearray => 1) ); # Go find all the modules find ({no_chdir => 1, wanted => sub { $self->load_api_modules($Fil +e::Find::name) }, follow =>1}, 'api'); } sub load_api_modules{ my $self = shift; my $filename = shift; if ($filename =~ /\.pm$/) { my @superclass = split(/\//, $filename); require "$filename"; my $name = $filename; $name =~ s#/#::#g; # Convert slashes (/) to :: substr($name, -3,3, ''); # Remove the .pm at the end $self->{$superclass[1].$superclass[2]} = new {split(/\./, $sup +erclass[$#superclass])}[0]; $self->logObj->log(location => 'Initialisation', message => 'l +oaded: '.$File::Find::name); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Dynamically load unknown modules
by fruiture (Curate) on Aug 27, 2002 at 16:31 UTC | |
by Ryszard (Priest) on Aug 28, 2002 at 08:29 UTC |