Re: variable module
- From: noreply@xxxxxxxxx (Gunnar Hjalmarsson)
- Date: Thu, 20 Dec 2007 20:19:51 +0100
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
.
- Follow-Ups:
- Re: variable module
- From: Chas. Owens
- Re: variable module
- References:
- variable module
- From: Octavian Rasnita
- variable module
- Prev by Date: Re: variable module
- Next by Date: Re: variable module
- Previous by thread: Re: variable module
- Next by thread: Re: variable module
- Index(es):