in reply to Loading a module at runtime...

I would assume that the error actually comes from your second eval. It is actually the same as:
eval $module::run . "()";
interpolating the $run variable from the module:: package. You should write this as
eval "${module}::run()";

Replies are listed 'Best First'.
SOLVED: Re: Loading a module at runtime...
by Anonymous Monk on Apr 08, 2003 at 07:22 UTC
    I've figured it out, though the solution doesn't make sense according to my understanding. Here is what now works:
       eval "require $module; import $module";
       eval "$module->run()";
    
    What's odd is that the class::method() syntax is usually used for class method invocation, whereas $object_ref->method() is used after you've already instantiated the class/module.
    In my case above, I haven't instantiated $module at all. If $module is Foo::Bar, then, after interpolation, it looks like Foo::Bar->run()
    Oh, well. It's odd (to me, at least), but it works. Michael
Re: Re: Loading a module at runtime...
by bart (Canon) on Apr 08, 2003 at 08:31 UTC
    Or, same thing:
    eval "$module\::run()";