?
Solved

Perl - how to USE a custom module that sits in a different directory

Posted on 2003-03-11
2
Medium Priority
?
207 Views
Last Modified: 2013-12-25
Hello
I would like to use a perl module that I have written.
Currently I call it thus:

use MYMODULE;

but this requires the module to sit next to the perl script.
This means that to use it for scripts in different dirs I have to cop the module around.  This is a nightmare for version control!

I have tried
use MYMODULE;
use MYMODULE.pm;
use /path/to/MYMODULE;
use /path/to/MYMODULE.pm;
use "/path/to/MYMODULE.pm";
etc but cannot seem to get it to work.

A solution is to put all scripts and this module in one cgi-src dir but this is not possible (some scripts are already in place and are linked to from elsewhere).

How can I call the custom module from another directory?

My server is Red Hat Linux release 7.3 (Valhalla) Kernel 2.4.19-rc3 on an i686 with Apache and perl 5.6.1.

Thanks

Daniel





0
Comment
Question by:dc197
2 Comments
 
LVL 17

Accepted Solution

by:
dorward earned 200 total points
ID: 8113318
I'm not an expert on Perl, so this could be wrong. But I believe:

use lib("/path/to/libs/", "/path/to/more/libs/", "/path/to/even/more/libs/", "../relative/libs/");
use MYMODULE;

will do the trick (where MYMODULE.pm is in one of the specified library directories)
0
 
LVL 5

Author Comment

by:dc197
ID: 8114435
Spot on.
Well done.
Thanks.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question