Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading Module using scalar variable

Status
Not open for further replies.

AcidHawk

Technical User
Mar 14, 2001
17
ZA
Hi

I have tried to write 2 different Modules. I want to be able to load either one or both based on an ini file that is read at the start of a perl script.

1) Something like read ini and create the mods array.
2) If the mods array has mod_a,mod_b load both using a foreach statement.

So my code would look something like this.

Code:
@mod_array = split /\,/, $line_in_ini_file;

foreach $mod(@mod_array) {
		use ModDir::"$mod";
	}

hmmm... what I want to happen is that if mod_a and mod_b are in the ini file it must load both mods.. either way.. if either of the mods are specified in the ini file it will load that one only.

What I get - Can't locate ModDir/.pm

mod_a and mod_b are in the ModDir dir under perl/lib. If it helps at all I'm running on Windows 2000 with Activestate perl 5.6.1 build 631

There are logical reason for wanting 2 seperate modules and I may want to use 1 or the other or both depending where I use my script.

any takers... any ideas would be great.

Cheers
Sean ----
Of All the things I've lost in my life it's my mind I miss the most.
 
Don't have time to write a complete reply, but you must use the "require" command for any dynamic module loading. The "use" is evaluated at compile time and thus must be static.

 
Thanks,

I worked this out about an hour after I had posted the question...

guess I just needed to clear my thoughts by putting it into writing.

use = compile time
require = run time

cheers
sean ----
Of All the things I've lost in my life it's my mind I miss the most.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top