Octavian Rasnita wrote:
I have a directory named "Questionnaire" which contains some modules
like "Files.pm", "MySQL.pm", and maybe others...
and I want to be able to choose the wanted module at runtime, using a
code like:
my $module = "Files";
require Questionnaire::$module;
my $obj = Questionnaire::$module->new();
<snip>
First please tell me if this is a good practice,
I can't see why it shouldn't be.
Then please tell me how to do this... if it is possible.
Assuming that the path to the directory right above Questionnaire is
included in @INC, this should work:
require "Questionnaire/$module.pm";
my $obj = "Questionnaire::$module"->new;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/