Why do you need to require() in a separate BEGIN block? the statement
use PmLoader qw{ ...args... }
is equivalent of
BEGIN { require PmLoader; PmLoader->import( qw{ ...args... } ); }
so you're already in a BEGIN block. Why not just require() everything at the end of import()?
As to using require() with variable names.. you need to do either of these:
require BAREWORD; require $filename; ## or require 'filename'
So what happens when you want to do the equivalent of
require CLASS::NAME;
but the "CLASS::NAME" portion is in a variable? well, eval(), of course, but you need to use eval STRING, not eval BLOCK:
my $module = "CLASS::NAME"; eval "require $module"; if( $@ ) { die $@; }
If you do eval{ require $module }, then require would try to load a file named "CLASS::NAME", which most likely don't exist
HTH
In reply to Re: use/require $MODULE (a variable)
by lestrrat
in thread use/require $MODULE (a variable)
by cadphile
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |