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

查看:44
本文介绍了如何将 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/ 文件夹中.我一直保持 使用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.

你可以调用 .pl 文件

You can call the .pl file with just

perl file.pl

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

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