Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to use relative path for a module

Reply
Thread Tools

How to use relative path for a module

 
 
dn_perl@hotmail.com
Guest
Posts: n/a
 
      10-27-2004
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.
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      10-27-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
David Efflandt
Guest
Posts: n/a
 
      10-27-2004
On 27 Oct 2004 13:46:10 -0700, (E-Mail Removed) <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FileUpload control doesn't work (fail in client side early stages) when path is relative i.e "\\path.." Oren ASP .Net 1 04-29-2007 04:20 PM
How do I convert an absolute path into a relative path Nigel Wilkinson Ruby 2 07-25-2005 07:37 PM
absolute path versus relative path in JSP Matt Java 3 07-08-2004 08:31 PM
Make a relative url path from an absolute path to another one Thomas Guettler Python 3 10-27-2003 04:41 PM



Advertisments