For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2005 > LIB path 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 LIB path question
James W. Thompson

2005-03-07, 8:56 pm

How is the lib path set with ActiveState Perl? Can I just drop my
custom *.pm files into the /site/lib or /lib folders under the
ActiveState installation?

--
James W. Thompson, II (New Orleans, LA)
John Doe

2005-03-07, 8:56 pm

Hello James

Am Montag, 7. M=E4rz 2005 22.32 schrieb James W. Thompson, II:
> How is the lib path set with ActiveState Perl?=20


Sidenote - To show the predefined paths, execute from command line:

perl -e 'print join "\n", @INC'

> Can I just drop my custom *.pm files into the /site/lib or /lib folders=20
>Y under the ActiveState installation?


The module search uses the order in which they occur in @INC.
The first module found with a certain name is used, even if there are sever=
al=20
modules with the same name in different paths.

You could put your modules in one of the paths shown, but usually it's bett=
er=20
to use your own directory/directories with your modules to separate them fr=
om=20
the system modules
(you can group them sensefully in different paths, and with a group of rela=
ted =20
modules you often have a directory tree with modules in it).

If you use your own directory, you must put a line like the following in yo=
ur=20
scripts to enable perl to find your modules:

use lib 'path_to_your_module_dir_tree';

this will change the @INC variable automatically by putting your path in th=
e=20
front of the path list.
(this way, you can override default modules in default paths, because your=
=20
path is searched first)


Documentation:
perldoc lib

(now I see that you will find about the same I've written above...)

> James W. Thompson, II (New Orleans, LA)


I hope you did understand my bad english :-)

greetings joe
James W. Thompson

2005-03-08, 3:56 am

Is there any method to more permanently modify the include path? I
didn't notice any environment variables, is it stored in the registry
or does ActiveState's Perl distro pull in anysort of configuration
file?


On Tue, 8 Mar 2005 00:42:11 +0100, John Doe
<security.department@tele2.ch> wrote:
> Hello James
>=20
> Am Montag, 7. M=E4rz 2005 22.32 schrieb James W. Thompson, II:
>=20
> Sidenote - To show the predefined paths, execute from command line:
>=20
> perl -e 'print join "\n", @INC'
>=20
>=20
> The module search uses the order in which they occur in @INC.
> The first module found with a certain name is used, even if there are sev=

eral
> modules with the same name in different paths.
>=20
> You could put your modules in one of the paths shown, but usually it's be=

tter
> to use your own directory/directories with your modules to separate them =

from
> the system modules
> (you can group them sensefully in different paths, and with a group of re=

lated
> modules you often have a directory tree with modules in it).
>=20
> If you use your own directory, you must put a line like the following in =

your
> scripts to enable perl to find your modules:
>=20
> use lib 'path_to_your_module_dir_tree';
>=20
> this will change the @INC variable automatically by putting your path in =

the
> front of the path list.
> (this way, you can override default modules in default paths, because you=

r
> path is searched first)
>=20
> Documentation:
> perldoc lib
>=20
> (now I see that you will find about the same I've written above...)
>=20
>=20
> I hope you did understand my bad english :-)
>=20
> greetings joe
>=20
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>=20
>=20



--=20
James W. Thompson, II (New Orleans, LA)
John Doe

2005-03-08, 3:56 am

Hi=20

Am Dienstag, 8. M=E4rz 2005 03.01 schrieb James W. Thompson, II:

>
> Is there any method to more permanently modify the include path? I
> didn't notice any environment variables, is it stored in the registry
> or does ActiveState's Perl distro pull in anysort of configuration
> file?


I only know ways under mod_perl:

a) in httpd.conf, with the line

PerlSetEnv PERL5LIB /path1:/another/path

b) In the startup.pl file (which muste be include with =20
PerlRequire /path/to/startup.pl) , with the line

use lib qw(/path1 /another/path);


Apart from that, I have the impression that the @INC is determined at compi=
le=20
time of perl itself.

Maybe somebody else knows the answer?


> [...]

John Doe

2005-03-08, 3:56 am

Hi again

Am Dienstag, 8. M=E4rz 2005 03.01 schrieb James W. Thompson, II:
> Is there any method to more permanently modify the include path? I
> didn't notice any environment variables, is it stored in the registry
> or does ActiveState's Perl distro pull in anysort of configuration
> file?


If no better solution will be available, here an idea for a workaround:

You could make a wrapper around perl, since the additional path(s) can be=20
given as argument(s) to the perl invocation. The wrapper could contain:

perl -Mlib=3D/your/SECOND/lib/path -Mlib=3D/your/FIRST/lib/path

(at least under linux)

According to the doc of v5.8.5 built for i686-linux

perldoc lib

you have to use unix style paths.

Don't know how to do that under windows, since I don't work with it for man=
y=20
years. Maybe some .BAT-file, maybe you have to name it "myperl" or rename t=
he=20
perl binary, don't know, sorry.

greetings joe

> [...]

Chris Devers

2005-03-08, 3:56 am

On Mon, 7 Mar 2005, James W. Thompson, II wrote:

> Is there any method to more permanently modify the include path?


Take a look at the PERL5LIB environment variable.

If you have this defined in a login script on *nix systems, you can add
directories to your standard @INC path.

The same will probably work with system environment variables on win32.

On the other hand, ActiveState seems to discourage $PERL5LIB:

http://aspn.activestate.com/ASPN/do...rl/install.html

....maybe they have something else in mind as a preferred approach, or
maybe they just object to having it defined before installing AS Perl,
but things might be fine once you're up & going with it...


--
Chris Devers
Sponsored Links







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

Copyright 2008 codecomments.com