Ok, you can't specify which module to load via @ARGV with use. use basically works its magic at compile time, and has already done its thing before $ARGV[0] is ever determined.
You might be able to do it with require. The documentation for use states the following:
It (use) is exactly equivalent to
BEGIN { require Module; import Module LIST; }
Please consider using variables other than $a and $b. Those variables have special meaning inside sort routines, and you'll create potential for all sorts of havoc if you steal them for your own use.
You know, Perl actually already offers you a better solution anyway. If your need is to supply the module name on the command line, don't rely on @ARGV. Instead, use Perl's command line switch, "-M", like this:
perl -MFoo myscript.pl
See perlrun for details.
An update:
You can probably still use -M even if your module resides along a path not specified in @INC. You can deal with this difficulty using either the -I[directory] switch, or the -f switch, which are also documented in perlrun.
Dave
In reply to Re: modules as variables
by davido
in thread modules as variables
by tcf03
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |