balachandran has asked for the wisdom of the Perl Monks concerning the following question:
I need to do something like this.
if ($ver > 2) { require 'Config'; } else { require 'Settings'; }
Config is actually the renamed newer version of Settings and both those modules expose the same constant(a hash named CONFIG, but the values are different). But I need this inside another module definition which uses the constants defined in those modules. $ver is a param to new() method of this module. So, I am not able to put it in a BEGIN block outside the module.
Since I am using a 'require', I get Can't use bare word CONFIG. Can someone help me with this please ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Dynamically requiring a module
by tobyink (Canon) on Jan 23, 2014 at 09:28 UTC | |
Re: Dynamically requiring a module
by choroba (Cardinal) on Jan 23, 2014 at 09:30 UTC | |
by balachandran (Novice) on Jan 28, 2014 at 07:58 UTC | |
Re: Dynamically requiring a module
by fishmonger (Chaplain) on Jan 23, 2014 at 15:16 UTC | |
Re: Dynamically requiring a module
by Bloodnok (Vicar) on Jan 23, 2014 at 14:33 UTC | |
Re: Dynamically requiring a module
by Anonymous Monk on Jan 23, 2014 at 14:33 UTC |
Back to
Seekers of Perl Wisdom