Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Setting the path when a module installs

by arcnon (Monk)
on Jan 04, 2006 at 23:13 UTC ( [id://521050]=perlquestion: print w/replies, xml ) Need Help??

arcnon has asked for the wisdom of the Perl Monks concerning the following question:

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.

Replies are listed 'Best First'.
Re: Setting the path when a module installs
by l3v3l (Monk) on Jan 04, 2006 at 23:43 UTC
    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
by sh1tn (Priest) on Jan 04, 2006 at 23:43 UTC
Re: Setting the path when a module installs
by Corion (Patriarch) on Jan 05, 2006 at 07:29 UTC

    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://521050]
Approved by thor
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-03-29 15:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found