Code Comments
Programming Forum and web based access to our favorite programming groups.Is it (possible / advisable) to use relative path for a module? I install 3 directories under a location specified by my client. The client may specify /apps/home or /home/usr/myproduct or whatever as the location where I should install my 3 directories. My directories are : myapp, mylib, myhelp. Let us say they are installed under /apps/home. One env variable which the user is required to set is $MYAPP_HOME="/apps/home/myapp" . The dir /apps/home/mylib contains a module : dir_list.pm . I want the perl script /apps/home/myhelp/option01 to use dir_list.pm . How can I do so using 'use dir_list' construct? "use ../mylib/dir_list" gives syntax error. Thanks in advance.
Post Follow-up to this messagedn_perl@hotmail.com wrote:
> I install 3 directories under a location specified by my client.
One option is to have the installer script - if you're using one - alter
the 'use lib' line in your scripts.
> Let us say they are installed under /apps/home. One env variable
> which the user is required to set is $MYAPP_HOME="/apps/home/myapp" .
If you're asking your users to set environment variables anyway, you
could simply have them set PERL5LIB to point to /apps/home/mylib.
Another option would be to do this:
use lib $ENV{'MYAPP_HOME'} . '/../mylib';
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
Post Follow-up to this messageOn 27 Oct 2004 13:46:10 -0700, dn_perl@hotmail.com <dn_perl@hotmail.com> wrote: > Is it (possible / advisable) to use relative path for a module? > > I install 3 directories under a location specified by my client. > The client may specify /apps/home or /home/usr/myproduct or whatever > as the location where I should install my 3 directories. > > My directories are : myapp, mylib, myhelp. > Let us say they are installed under /apps/home. One env variable > which the user is required to set is $MYAPP_HOME="/apps/home/myapp" . > The dir /apps/home/mylib contains a module : dir_list.pm . > I want the perl script /apps/home/myhelp/option01 to use dir_list.pm . > How can I do so using 'use dir_list' construct? > "use ../mylib/dir_list" gives syntax error. You could do it realive to the current working directory "./": use lib "./mylib"; # puts this 1st in @INC use "dir_list"; However, you have to make sure the current working dir is what you think it is. For example, in CGI called as SSI, the working dir is the dir of the SSI page, not the CGI script.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.