Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

How to use relative path for a module
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.

Report this thread to moderator Post Follow-up to this message
Old Post
dn_perl@hotmail.com
10-28-04 01:56 AM


Re: How to use relative path for a module
dn_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

Report this thread to moderator Post Follow-up to this message
Old Post
Sherm Pendley
10-28-04 01:56 AM


Re: How to use relative path for a module
On 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.

Report this thread to moderator Post Follow-up to this message
Old Post
David Efflandt
10-28-04 01:56 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:50 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.