如何在本地目录中安装CPAN模块? [英] How can I install a CPAN module into a local directory?

查看:384
本文介绍了如何在本地目录中安装CPAN模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用托管的Linux计算机,因此我没有写权限 进入/usr/lib目录.

I'm using a hosted Linux machine so I don't have permissions to write into the /usr/lib directory.

当我尝试通过常规方式安装CPAN模块时:

When I try to install a CPAN module by doing the usual:

perl Makefile.PL
make test
make install

该模块被提取到blib/lib/文件夹中.我保留了use blib/lib/ModuleName,但是编译器仍然说模块不能 成立.我尝试将.pm文件复制到本地目录并保留 require ModuleName,但仍然给我一些错误.

That module is extracted to a blib/lib/ folder. I have kept use blib/lib/ModuleName but it still the compiler says module can not be found. I have tried copying the .pm file into local directory and kept require ModuleName but still it gives me some error.

如何将模块安装到其他目​​录中并使用它?

How can I install a module into some other directory and use it?

推荐答案

我有一个类似的问题,我什至无法安装local :: lib

I had a similar problem, where I couldn't even install local::lib

我创建了一个安装程序,将模块安装在相对于.pl文件的某个位置

I created an installer that installed the module somewhere relative to the .pl files

安装过程如下:

perl Makefile.PL PREFIX=./modulos
make
make install

然后,在需要模块的.pl文件中,该文件位于./

Then, in the .pl file that requires the module, which is in ./

use lib qw(./modulos/share/perl/5.8.8/); # You may need to change this path
use module::name;

其余文件(makefile.pl,module.pm等)不需要更改.

The rest of the files (makefile.pl, module.pm, etc) require no changes.

您只需使用.p文件即可调用.pl文件

You can call the .pl file with just

perl file.pl

这篇关于如何在本地目录中安装CPAN模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆