in reply to use/require $MODULE (a variable)
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use/require $MODULE (a variable)
by cadphile (Beadle) on Mar 17, 2002 at 03:11 UTC | |
by cadphile (Beadle) on Mar 17, 2002 at 04:47 UTC | |
by lestrrat (Deacon) on Mar 17, 2002 at 04:58 UTC | |
by cadphile (Beadle) on Mar 18, 2002 at 08:08 UTC | |
by lestrrat (Deacon) on Mar 18, 2002 at 08:26 UTC | |
by cadphile (Beadle) on Mar 18, 2002 at 09:08 UTC |