For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > setting PERL5LIB path









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 setting PERL5LIB path
Manish Sapariya

2005-04-14, 8:56 pm

Hi List,
I have default MIME module installed and I have
installed the lated version in one of my own directory.

Any my perl code needs the latest version which I have
installed in local_perl_lib.

How do I instruct perl interpreter to use the latest one
in the $PERL5LIB and not the one in the default installation.

Thanks,
Manish
Zentara

2005-04-15, 3:56 pm

On Thu, 14 Apr 2005 18:27:23 +0530, manishs@gs-lab.com (Manish Sapariya)
wrote:

>Hi List,
>I have default MIME module installed and I have
>installed the lated version in one of my own directory.
>
>Any my perl code needs the latest version which I have
>installed in local_perl_lib.
>
>How do I instruct perl interpreter to use the latest one
>in the $PERL5LIB and not the one in the default installation.


When perl searchs @INC for modules, it will grab the first
one it finds that matches the name. So what you want to do is
make sure that 'local_perl_lib' is first in the array.

At the top of your script put:

BEGIN { unshift(@INC, 'local_perl_lib')}




--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Manish Sapariya

2005-04-18, 8:55 am

Hi,
So can't I set PERL5LIB so that the perl will search first my local lib
directory and then system lib directory.

Something like setting PATH variable to /usr/local/bin and then /usr/bin.

I want to do this because certain CPAN modueles which I use in my
program are of higher version than the default version installed by
perl. And I dont want to upgrade the system modules and still use the
newer once to be used by CPAN modules.

Thanks,
Manish

On 04/15/2005 06:23 PM, Zentara wrote:
> On Thu, 14 Apr 2005 18:27:23 +0530, manishs@gs-lab.com (Manish Sapariya)
> wrote:
>
>
>
>
> When perl searchs @INC for modules, it will grab the first
> one it finds that matches the name. So what you want to do is
> make sure that 'local_perl_lib' is first in the array.
>
> At the top of your script put:
>
> BEGIN { unshift(@INC, 'local_perl_lib')}
>
>
>
>

John Doe

2005-04-18, 8:55 am

Am Montag, 18. April 2005 07.12 schrieb Manish Sapariya:
> Hi,
> So can't I set PERL5LIB so that the perl will search first my local lib
> directory and then system lib directory.
>
> Something like setting PATH variable to /usr/local/bin and then /usr/bin.
>
> I want to do this because certain CPAN modueles which I use in my
> program are of higher version than the default version installed by
> perl. And I dont want to upgrade the system modules and still use the
> newer once to be used by CPAN modules.
>
> Thanks,
> Manish


II didn't do it myself, but there may be a possibility to set the environment
variable PERLLIB or PERL5LIB in a login script, see

perlfaq -q INC
(at the bottom on Perldoc v3.13, under perl v5.008005 for linux)

If you use mod_perl, you can modify @INC in the startup file (not permanently
as you wish)
[color=darkred]
> On 04/15/2005 06:23 PM, Zentara wrote:

If I'm not wrong, this is the same as

use 'local_perl_lib'

since this prepends the additional lib to @INC anyway.

HTH, joe
Zentara

2005-04-18, 3:56 pm

On Mon, 18 Apr 2005 10:42:04 +0530, manishs@gs-lab.com (Manish Sapariya)
wrote:

>Hi,
>So can't I set PERL5LIB so that the perl will search first my local lib
>directory and then system lib directory.
>
>Something like setting PATH variable to /usr/local/bin and then /usr/bin.
>


Yes, you can try to do it that way.

Set the environment variable in your .bashrc like you
would your $PATH

PERL5LIB=/home/user/my_perl5lib:$PERL5LIB
export PERL5LIB

But I'm not sure myself, whether this will always work.
It is more certain to work, the other way I mentioned, by
directly manipulating the @INC in each script.
Otherwise you may end up with hard to find bugs,
where your scripts are using some old module you have
in my_perl5lib, instead of the newer ones in @INC.






--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Manish Sapariya

2005-04-26, 8:57 am

Hi,
I was going through perldoc perlrun and here it has to say about
PERL5LIB:

========================================
=======
PERL5LIB A colon-separated list of directories in which to look for
Perl library files before looking in the standard library
and the current directory. Any architecture-specific
directories under the specified locations are automatically
included if they exist. If PERL5LIB is not defined, PERL-
LIB is used.

When running taint checks (either because the program was
running setuid or setgid, or the -T switch was used), nei-
ther variable is used. The program should instead say:

use lib "/my/directory";
========================================
=======
But in my case it did look into the local libs but didnt use them....
did i miss something??


Thanks,
Manish


On 04/18/2005 04:49 PM, Zentara wrote:
> On Mon, 18 Apr 2005 10:42:04 +0530, manishs@gs-lab.com (Manish Sapariya)
> wrote:
>
>
>
>
> Yes, you can try to do it that way.
>
> Set the environment variable in your .bashrc like you
> would your $PATH
>
> PERL5LIB=/home/user/my_perl5lib:$PERL5LIB
> export PERL5LIB
>
> But I'm not sure myself, whether this will always work.
> It is more certain to work, the other way I mentioned, by
> directly manipulating the @INC in each script.
> Otherwise you may end up with hard to find bugs,
> where your scripts are using some old module you have
> in my_perl5lib, instead of the newer ones in @INC.
>
>
>
>
>
>

Sponsored Links







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

Copyright 2009 codecomments.com