in reply to Controlling "use" statements
There's a gotcha to require semantics though, it requires a "bareword", which is fine if you want to do something like this:
if ($DEBUG) { require Data::Dumper; import Data::Dumper; }
But if you want to put the module names in variables, then you'll probably need something like this:
(Note, some folks are down on eval STRING, but this is a case where it's necessary.)my @debug_modules = qw( Data::Dumper CGI Test::Deep ); foreach my $mod (@debug_modules) { eval "require $mod"; import $mod; }
If you want to read up on this, look into things like "perlmod", and the "use" and "require" sections of "perlfunc". Do not however, waste your time looking for "import" in perlfunc. It's not a "function", it's more like a reserved name for a subroutine.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Controlling "use" statements
by nodice (Initiate) on Jun 13, 2007 at 19:25 UTC | |
by ikegami (Patriarch) on Jun 13, 2007 at 19:50 UTC | |
by shmem (Chancellor) on Jun 13, 2007 at 19:44 UTC | |
|
Re^2: Controlling "use" statements
by ysth (Canon) on Jun 14, 2007 at 23:05 UTC |