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->();
In reply to Re: loading modules at runtime
by ikegami
in thread loading modules at runtime
by zer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |