in reply to Recommendation for dynamically "using" modules
The problem is that myuse() would be executed at run-time instead of compile-time. In which case the symbols are probably less useful. If the symbols being exported are non-code (i.e. exported variables), then use strict will have already killed the script at compile-time because the variables were not declared. Ditto for any subs that are imported that need special parsing (e.g. you want to use them without parentheses, or they have interesting prototypes). Importing is something that really needs to be done at compile-time; hence use, or at a push BEGIN.
What exactly are you hoping to achieve? If you want to combine many use Foo, use Bar, use Baz statements into a single statement, then look at Syntax::Collector and/or Import::Into. If you want to conditionally load modules, look at if. If you want to select amongst several backend modules implementing the same function, there's Module::Implementation. If you don't need to import symbols at all, and are loading modules that will e.g. be used as classes, then run-time loading is fine, and I'd recommend Module::Runtime, Class::Load, or (if you're in an experimental kind of mood) perhaps Module::Quote.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recommendation for dynamically "using" modules
by McA (Priest) on Jul 11, 2013 at 08:34 UTC |