LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-13-2005, 01:25 PM   #1
rigel_kent
Member
 
Registered: Nov 2004
Posts: 64

Rep: Reputation: 15
Question Using uninstalled Modules


Hi there,

This is a question I have for some time, but I can't find the answer. How do we use a Module ( or a package with several ones ) written in Perl, but without installing it in the library of the server ( the hosts, generally, don't install them... )?

With small ones, they just function right - but with others no.

Does anyone knows a solution to this?

Kind regards,

Rigel_Kent
 
Old 06-14-2005, 11:53 AM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,990

Rep: Reputation: 66
You can't use a module without making the code accessible to Perl in some way. So this all depends on what you mean by “install”.

If your Perl module has a modulename.pm file, then you can include it with:
Code:
use modulename;
This will search for modulename.pm on every directory listed in @INC, in turn.

So all you need to do to install a module is add the path to the module to @INC:
Code:
BEGIN {
 unshift @INC, "/path/to/module/";
};
use modulename;
You need to put the code to modify @INC in a BEGIN block in order for it to be changed before the use statement.

If your module name contains :: then the .pm file lives in a sub-directory; you need to put the parent of the sub-directory into @INC. (e.g. if your module is named Test::Module and is in /home/testuser/perl/test/module.pm then you would want to add "/home/testuser/perl/" to @INC).

You can also modify the search path on the command-line rather than in a BEGIN block:
Code:
perl -I'/path/to/module/' …
 
Old 06-14-2005, 12:26 PM   #3
rigel_kent
Member
 
Registered: Nov 2004
Posts: 64

Original Poster
Rep: Reputation: 15
Yep...

Hi,

Thanks for the reply. I'll try it - and I believe it will work. I'll let you know.

Thanks again,

Rigel_Kent
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
uninstalled Mandrake10 Haggis56 Linux - Newbie 2 01-12-2005 07:30 PM
Can UP2DATE be uninstalled? How exactly??? jdruin Linux - Software 5 10-22-2003 06:29 PM
RPM, installed but uninstalled??? Daem0hn Linux - General 8 07-19-2003 03:50 AM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - General 1 01-24-2002 01:50 AM
Re: modprobe: Note: /etc/modules.conf is more recent than lib/modules/2.4.9/modules.d Andy.M Linux - Newbie 2 01-24-2002 01:40 AM


All times are GMT -5. The time now is 01:51 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration