Damn it's tough searching the web with terms like "perl", "dynamic", "use", etc...
Anyway, I'd like to know if it's possible to do the following:
$dynamic_configuration = 'CONF-A';
use $dynamic_configuration;
Then my PERL program would have the variables and methods contained in CONF-A.pm at least this is what I would like to happen...rather than the compile errors.
...BUT...that doesn't seem to work, so is there a way to accomplish this?
Here are some ideas I've thought of already:
if ($A) {
use CONF-A;
} elsif ($B) {
use CONF-B;
} elsif ($C) {
use CONF-C;
}
I'd rather not have to change all my programs to add CONF-D, E, and F.
The other possibility is that there would be a CONF.pm file containing:
%conf = (CONF-A => 'foo', etc...,
CONF-B => 'bar', etc...,
CONF-C => 'baz', etc...);
The problem with that is that the CONF.pm file can get very large and I would prefer to keep such a large configuration out of memory and not have such a monster to edit.
Would it be possible to use "require" instead of "use"? I'm not entirely sure how that would work, I thought maybe I could do this:
$x = 'A';
eval "require CONF-$x";
import ????? qw(var1 var2...);
But the ????? part trips me up.
...ack...
Anyone have any pointers or solutions to this?
THANKS!
Tosh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.