如何找到Perl模块的安装位置? [英] How can I find out where a Perl module is installed?
问题描述
如何按名称获取已安装的Perl模块的路径,
例如Time::HiRes
?
How do get the path of a installed Perl module by name,
e.g. Time::HiRes
?
我想要这个只是因为我必须在SGE Grid Engine系统的不同节点上运行我的perl脚本.有时,甚至可以使用其他用户名运行.
I want this just because I have to run my perl script on different nodes of a SGE Grid Engine system. Sometimes, even run as other username.
我可以使用CPAN.pm为自己安装软件包,但是对于没有chmod 666文件夹的其他用户来说,安装它并不是那么容易.
I can use CPAN.pm to install packages for myself, but it is not so easy to install for other users without chmod 666 on folders.
推荐答案
注意:此解决方案建议使用必须自行创建的(自授权)实用程序 >下载.虽然它提供了我认为有用的功能,但并非所有人都可以选择先安装第三方解决方案.
Note: This solution proposes use of a (self-authored) utility that you must download. While it offers what I believe to be helpful features, installing a third-party solution first is not an option for everyone.
我已经创建> whichpm
(跨平台CLI (Linux,macOS,Window),它按模块(软件包)名称查找已安装的Perl模块,并可以选择报告有关它们的信息,包括检测意外重复.
I've created whichpm
, a cross-platform CLI (Linux, macOS, Window) that locates installed Perl modules by module (package) name, and optionally reports information about them, including detection of accidental duplicates.
示例
# Locate the Data::Dumper module.
$ whichpm Data::Dumper
/usr/lib/perl/5.18/Data/Dumper.pm
# Locate the Data::Dumper module, and also print
# version information and core-module status.
$ whichpm -v Data::Dumper
Data::Dumper 2.145 core>=5.005 /usr/lib/perl/5.18/Data/Dumper.pm
# Locate the Data::Dumper module and open it in your system's default text
# editor.
$ whichpm -e Data::Dumper
# Look for accidental duplicates of the Foo::Bar module.
# Normally, only 1 path should be returned.
$ whichpm -a Foo::Bar
/usr/lib/perl/5.18/Foo/Bar.pm
./Foo/Bar.pm
# Print the paths of all installed modules.
$ whichpm -a
安装
先决条件:已安装 Perl v5.4.50或更高版本的 Linux , macOS 或 Windows .
[sudo] npm install whichpm -g
手动安装(macOS和Linux)
- 将 CLI 下载为
whichpm
. - 使用
chmod +x whichpm
将其设为可执行文件. - 将其移动或符号链接到
$PATH
中的文件夹,例如/usr/local/bin
(OSX)或/usr/bin
(Linux). - Download the CLI as
whichpm
. - Make it executable with
chmod +x whichpm
. - Move it or symlink it to a folder in your
$PATH
, such as/usr/local/bin
(OSX) or/usr/bin
(Linux).
Manual installation (macOS and Linux)
这篇关于如何找到Perl模块的安装位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!