?
Solved

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

Posted on 2003-03-11
2
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

764 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