'use lib' question

N

nan li

Hello,
I have a simple file below.

#t11.pl
use strict;
use warnings;

use Env qw(XYZ);
use lib "$XYZ";

I tried to set up the library path for perl. But I got the following
error.
perl -c t11.pl
Use of uninitialized value in string at t11.pl line 5.
Empty compile time value given to use lib at t11.pl line 5
t11.pl syntax OK

I guess the problem is that 'use lib' runs at compile time and $XYZ is
not available at that time. Is my guess correct? If so, is there any
good way I can do the same thing at run time ?

Thanks a lot.
 
P

Paul Lalli

#t11.pl
use strict;
use warnings;

use Env qw(XYZ);
use lib "$XYZ";

I tried to set up the library path for perl. But I got the following
error.


Use of uninitialized value in string at t11.pl line 5.
Empty compile time value given to use lib at t11.pl line 5
t11.pl syntax OK

I guess the problem is that 'use lib' runs at compile time and $XYZ is
not available at that time. Is my guess correct? If so, is there any
good way I can do the same thing at run time ?

Don't use the Env module. Just use the actual environment variable.

use lib $ENV{XYZ};

Paul Lalli
 
N

nan li

Don't use the Env module. Just use the actual environment variable.

use lib $ENV{XYZ};

Paul Lalli

But if I use this, I still get the warning:

Empty compile time value given to use lib at t11.pl line 7

Nan
 
N

nan li

nan li said:
On Feb 2, 3:35 pm, "nan li" <[email protected]> wrote:
[..]
Use of uninitialized value in string at t11.pl line 5.
Empty compile time value given to use lib at t11.pl line 5
t11.pl syntax OK
[..]
use lib $ENV{XYZ};
Paul Lalli
But if I use this, I still get the warning:

No, no, you get a different one.
Empty compile time value given to use lib at t11.pl line 7

Maybe because XYZ is empty...

You are right. I didn't set XYZ :-( Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top