For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Module Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Module Question
Wayne Happ

2006-01-10, 4:02 am


I have a question about finding a module at rutime.

Here's what I would like to do.

push(@INC, @notknowntillrunning);

use lib 'notknowntill running';

use foo;

My problem is I do not know the where the Module will be till the script
runs. Perl won't compile the script because at time of compilation the
enviroment is not known.



Paul Lalli

2006-01-10, 4:02 am

Wayne Happ wrote:
> I have a question about finding a module at rutime.
>
> Here's what I would like to do.
>
> push(@INC, @notknowntillrunning);
>
> use lib 'notknowntill running';


You need to make up your mind. 'use lib' effectively does a 'push
@INC', but does it at compile time. You said you wanted to do this at
runtime, so use the 'push @INC' variant.

> use foo;


'use' does two things, and does them both at compile time. If you want
what use does to happen at run time, simply call those two things
explicitly:

require foo;
foo->import;

> My problem is I do not know the where the Module will be till the script
> runs. Perl won't compile the script because at time of compilation the
> enviroment is not known.


"won't compile" is not especially helpful without knowing what the
compilation error is. Why did you choose not to share that information
with us?

For more information:
perldoc -f use
perldoc lib
perldoc perlvar (search for @INC)

Paul Lalli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com