Fellow monks,
for some module, I need to include other modules based on run-time information. Here's roughly what I am doing right now:
sub init { my ($someModule, $someCondition) = @_; eval "use Acme::$someModule"; eval "use Funky::Library" if $someCondition; } init("Bleach", 1);
Now, for some reason, I don't really like eval "$some $code". I fear the performance hit (although I have no idea whether there really is one), and more importantly I just don't like the thought of compiling during runtime. I guess I could rewrite the code using require and import, like this:
sub init { my ($someModule, $someCondition) = @_; require "Acme/$someModule.pm"; import "Acme/$someModule.pm"; if $someCondition { require Funky::Library; import Funky::Library qw(grooves moves); } } init("Bleach", 1);
Is this the canonical way to solve that problem; are there any issues I need to be aware of?
In reply to run-time module usage by crenz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |