problem importing modules - please help 
Author Message
 problem importing modules - please help

Okay, here's the situation.

I have a perl file which runs some procedures and first of all imports
some perl modules.The perl modules that are imported each in turn
import other modules.

Now, the main perl program and each of the subsequent modules
all import a module called 'settings'.

use settings ;

what I'd very much like to do is to dynamically choose at run time
which settings module to have loaded in each file.

I've been trying something like this.
run like this

command line -> perlprogram mysettings

In perlprogram.pl

$variable = $ARGV[0] ;
eval "use $variable" ;

in each of the imported modules I have then said
eval "use $variable" ;

what happens is that the value is not kept throughout
and I get this error message - BEGIN not safe after errors.

How can I get round this?

Thanks

David



Wed, 18 Jun 1902 08:00:00 GMT  
 problem importing modules - please help

Quote:

> In perlprogram.pl

> $variable = $ARGV[0] ;
> eval "use $variable" ;

> in each of the imported modules I have then said
> eval "use $variable" ;

In other packages (modules) you gotta use the fully qualified name of
$variable. That is $main::variable (or IIRC the equivalent $::variable).

--
Jakob



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. problem importing modules - please help

2. Strange problem installing Win32-OLE-0.1403 module (PLEASE HELP )

3. problem with istallation o module:help please!

4. Perl module problem, please help!!

5. Perl module problem, please help!!

6. HELP: (please help, wizards) Memory problems

7. importing variable into module

8. Import Module/Function - Undefined subroutine

9. Import from required module

10. PERLFUNC: import - patch a module's namespace into your own

11. Import from module

12. PERLFUNC: import - patch a module's namespace into your own

 

 
Powered by phpBB® Forum Software