我在哪里安装我编写的 Perl 模块? [英] Where do I install Perl modules that I wrote?

查看:53
本文介绍了我在哪里安装我编写的 Perl 模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些模块,并试图运行它们.我如何知道从哪里获取模块?

I wrote some modules, and trying to run them. How I tell where to take the module from?

我在 Windows 中编写代码,并尝试将它放在 c:\perl\lib 中,但没有帮助.

I am writing in Windows, and tried to put it in c:\perl\lib but it didn't help.

我可以把它和调用模块的文件放在同一个目录下吗?

Can I put it in the same directory, as the file that calls the module?

推荐答案

Perl 使用以下路径:

Perl uses the paths in:

@INC

搜索模块.(.pm 文件)

to search for modules. (.pm files)

如果你:

perl -e 'print join "\n", @INC;'

您将看到当前正在搜索模块的路径.(这个@INC 列表被编译成 perl 可执行文件)

you'll see what paths are currently being searched for modules. (This @INC list is compiled into the perl executable)

然后你可以:

BEGIN { unshift @INC, 'C:\mylibs' }

use lib 'C:\mylibs'

并将 MyModule.pm 放在 C:\mylibs 中以启用:

and place MyModule.pm inside C:\mylibs to enable:

use MyModule;

这篇关于我在哪里安装我编写的 Perl 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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