Thompson, Glenn wrote:
> I'm trying to add my own module "DEGS::ldegs" to a Perl program.
> However, this module will part of a distribution called "RGSE",
> which could be installed on a different path on different peoples PCs.
> However, it will always be in the directory "$ENV{RGSE}/lib".
> 
> The problem is when I run the program I get an error like:
> 
> "Empty compile time value given to use lib at
> /home/gtho/Rgse/bin/depsol-gmt line 44" 
> 
> This presumably is because "use lib" cannot be used on a variable
> that is undefined at compile time. 

I'm assuming the "use lib" line below is line 44. This doesn't make sense.
If you look at the source code to lib.pm, you'll see that this error is
raised if you pass an empty string to "use lib" like:

   use lib ('');

I can't get that error to happen, even if the RSGE environment variable
isn't defined. In that case, the use lib would degrade to

   use lib "/lib"

which, although not correct, wouldn't raise the error. Something else must
be going on. Distill it down to the minimum program that exhibits the error
(just one line?)

> 
> Now I know I can run the program in the following way:
>       perl -I$ENV{RGSE}/lib myprogram.pl

No, that would be

   $ perl -I${RSGE}/lib myprogram.pl

You need to speak shell here, not Perl.

> 
> which could easily be put in a wrapper shell script.
> 
> But is there anyway of avoiding this, and have "use lib" work on
> $ENV{RGSE} "dynamically"? Hopefully I'm missing something really
> simple here! 

It should work as you're doing it. You may want to check that RSGE is
defined (needs to be inside a BEGIN block).

> 
> Here is a snippet from the program:
> 
>       use lib "$ENV{RGSE}/lib"; # directory when DEGS::ldegs is contained

Do you get the error if you put this line in a script all by itself?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to