use lib

use lib

am 09.06.2006 12:09:29 von rembremading

Is there a way to include several library paths with
use lib
at once, so that I can do something like

use lib $ENV{'PERL_LIBRARY_PATHS'};

The following seems not to work ...

@array = split(/ /$ENV{'PERL_LIBRARY_PATHS'});
foreach $array_item (@array){
use lib $array_item;
}

Re: use lib

am 09.06.2006 12:22:55 von Thomas Wittek

rembremading schrieb:
> Is there a way to include several library paths with
> use lib
> at once,
Try:

unshift @INC, qw(/some/path /some/other/path);

You may want to put this into a BEGIN block:

BEGIN {
...
}

-Thomas

Re: use lib

am 09.06.2006 12:27:13 von rvtol+news

rembremading schreef:

> Is there a way to include several library paths with
>
> use lib
>
> at once, so that I can do something like
>
> use lib $ENV{'PERL_LIBRARY_PATHS'};
>
> The following seems not to work ...
>
> @array = split(/ /$ENV{'PERL_LIBRARY_PATHS'});
> foreach $array_item (@array){
> use lib $array_item;
> }

See perldoc lib.

See perldoc -f split.


I doubt that

use lib split(' ', $ENV{'PERL_LIBRARY_PATHS'}) ;

will work, because the separator is likely ':', and there may be empty
list members.

--
Affijn, Ruud

"Gewoon is een tijger."

Re: use lib

am 09.06.2006 13:24:04 von rembremading

I export the PERL_LIBRARY_PATHS environment variable by myself, so that I
can have the paths separated by whatever I like. But it doesn't work
anyway.

However I found out that

BEGIN { use lib split(':', $ENV{'PERL_LIBS'}); }

works.

Dr.Ruud wrote:

> rembremading schreef:
>
>> Is there a way to include several library paths with
>>
>> use lib
>>
>> at once, so that I can do something like
>>
>> use lib $ENV{'PERL_LIBRARY_PATHS'};
>>
>> The following seems not to work ...
>>
>> @array = split(/ /$ENV{'PERL_LIBRARY_PATHS'});
>> foreach $array_item (@array){
>> use lib $array_item;
>> }
>
> See perldoc lib.
>
> See perldoc -f split.
>
>
> I doubt that
>
> use lib split(' ', $ENV{'PERL_LIBRARY_PATHS'}) ;
>
> will work, because the separator is likely ':', and there may be empty
> list members.
>

Re: use lib

am 09.06.2006 14:23:06 von nobull67

rembremading wrote upside-down:

> However I found out that
>
> BEGIN { use lib split(':', $ENV{'PERL_LIBS'}); }
>
> works.

As would

BEGIN { BEGIN { use lib split(':', $ENV{'PERL_LIBS'}); } }

or

BEGIN { BEGIN { BEGIN { use lib split(':', $ENV{'PERL_LIBS'}); } } }

or simply

use lib split(':', $ENV{'PERL_LIBS'});

Re: use lib

am 09.06.2006 17:34:25 von John Bokma

rembremading wrote:

> Is there a way to include several library paths with
> use lib
> at once, so that I can do something like
>
> use lib $ENV{'PERL_LIBRARY_PATHS'};
>
> The following seems not to work ...
>
> @array = split(/ /$ENV{'PERL_LIBRARY_PATHS'});
> foreach $array_item (@array){
> use lib $array_item;
> }

Why don't you user PERL5_LIB, which IIRC can handle more then one path.

--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/