in reply to How to use modules dynamically?
Use holli's suggestion if you want to figure out the name of the module at runtime, and then load it.
If the module name can be known at compile time through some logic with options or environment or variables set in a BEGIN block, the if module may be for you.
The if.pm module is included with recent perl, but is available on CPAN and works with fairly old perls.BEGIN { $cond = whatever; } use if $cond < 0, 'Foo::Bar'; use if $cond == 0, 'Foo::Baz'; use if $cond > 0, 'Foo::Quux';
The problem with leaving off the use MyModule; statement is simply that thw module is never loaded then.
After Compline,
Zaxo
|
|---|