Setting the path when a module installs
arcnon
created: 2006-01-04 18:13:29
what is the best practice for setting the path of a library if it isn't in their path?

warn them to set the path?

try and set it myself like: `set path=($path /usr/local/bin)`; or `PATH=${PATH}:/usr/local/bin`;

Is their a standard for this type of thing when writing a module?

edit: sorry that I wasn't specific enough... On OSX when you install allegro the path to the conf file is at /usr/local/bin/allegro-config

When you try and install the perl allegro pm it can't find this file because it isn't in the path. I thought I might write a patch for it. That why I am interested in what is the best practice for this type of thing. So makefile.pl can suck the info it needs and I do it the right way.

Re: Setting the path when a module installs
created: 2006-01-04 18:43:56
The pragma use lib.


Re: Setting the path when a module installs
created: 2006-01-04 18:43:58
since %ENV is a (special) hash, if you are going to put more custom libs or custom programs into a specific location, I would just set it for your script with something like:
$ENV{'PATH'} = q(/bin:/usr/bin:/usr/local/bin:/home/custom_stuff);
Re: Setting the path when a module installs
created: 2006-01-05 02:29:34

Note that you can only set the environment variables for your child processes and not for your parent process (unless you're on Win32).

So if you're running child processes (like a C compiler) from your Makefile.PL, the following will work:

use Config '%Config';
my $allegro_dir = '/usr/local/bin/';
$ENV{PATH} .= ":" . $allegro_dir;
...

The following won't do what you want though:

`PATH=$ENV{PATH}:$allegro_dir`;

because that will launch a child process, which sets the PATH environment variable and then ends. And the changes are gone with the end of the child too.

perlmonks.org content © perlmonks.org and arcnon, Corion, l3v3l, sh1tn

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03