Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm wrestling with a little problem whose solution seems close at hand but remains elusive. I'd like to be able to use different modules depending on runtime conditions.
The modules that I would like to swap between export many functions, and in general, these functions have typically been called like someFunction. NB: someFunction is not passed null as in someFunction();
perlsub was enlightening but didn't quite answer this question.
Might someone be able to explain this to me? Thanks in advance for your wisdom.use ModuleA; function_from_ModuleA; # This works.... function_from_ModuleA(); # and so does this... # Ah, but here's the rub... eval "use $desired_module"; ... function_from_desired_module; # nope. bareword. function_from_desired_module(); # works!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: eval use, exported functions, barewords
by liz (Monsignor) on Nov 07, 2003 at 18:48 UTC | |
|
Re: eval use, exported functions, barewords
by perrin (Chancellor) on Nov 07, 2003 at 18:46 UTC | |
|
Re: eval use, exported functions, barewords
by broquaint (Abbot) on Nov 07, 2003 at 18:40 UTC | |
by diotalevi (Canon) on Nov 07, 2003 at 18:48 UTC | |
|
Re: eval use, exported functions, barewords
by simonm (Vicar) on Nov 07, 2003 at 18:50 UTC |