in reply to loading modules at runtime
I presume the module name is in a variable.
I also presume you have no need to import symbols.
my $plugin = ...; my $pm = $plugin; $pm =~ s{::}{/}g; $pm .= '.pm'; eval { require $pm } or die("Unable to load plugin $plugin: $@\n"); # Example static method call. $plugin->method(); # Example function call. my $func = do { no strict 'refs'; *{"${plugin}::func"}{CODE} } or die("Undefined function func in plugin $plugin\n"); $func->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: loading modules at runtime
by blazar (Canon) on Oct 14, 2006 at 21:52 UTC | |
by ikegami (Patriarch) on Oct 15, 2006 at 01:23 UTC | |
|
Re^2: loading modules at runtime
by phaylon (Curate) on Oct 16, 2006 at 13:05 UTC | |
|
Re^2: loading modules at runtime
by zer (Deacon) on Oct 17, 2006 at 00:20 UTC |