用例
我的系统管理员刚刚通过rpm
安装了一个Perl模块,尽管我可以在单行中成功use
,但我想知道模块的安装位置。
我显然可以梳理@INC
中的每个路径位置,但Perl有没有办法告诉我它从哪里成功加载模块?
答案 0 :(得分:6)
那是%INC
哈希的用途。它显示了加载模块的位置。
$ perl -MDBI -MData::Dumper -E'say Dumper \%INC'
$VAR1 = {
'XSLoader.pm' => '/usr/share/perl5/XSLoader.pm',
'warnings/register.pm' => '/usr/share/perl5/warnings/register.pm',
'List/Util.pm' => '/usr/local/lib64/perl5/List/Util.pm',
'warnings.pm' => '/usr/share/perl5/warnings.pm',
'DBI.pm' => '/usr/lib64/perl5/vendor_perl/DBI.pm',
'overloading.pm' => '/usr/share/perl5/overloading.pm',
'Config.pm' => '/usr/lib64/perl5/Config.pm',
'Carp.pm' => '/usr/share/perl5/vendor_perl/Carp.pm',
'bytes.pm' => '/usr/share/perl5/bytes.pm',
'Exporter/Heavy.pm' => '/usr/share/perl5/vendor_perl/Exporter/Heavy.pm',
'Scalar/Util.pm' => '/usr/local/lib64/perl5/Scalar/Util.pm',
'strict.pm' => '/usr/share/perl5/strict.pm',
'Exporter.pm' => '/usr/share/perl5/vendor_perl/Exporter.pm',
'vars.pm' => '/usr/share/perl5/vars.pm',
'constant.pm' => '/usr/share/perl5/vendor_perl/constant.pm',
'overload.pm' => '/usr/share/perl5/overload.pm',
'DynaLoader.pm' => '/usr/lib64/perl5/DynaLoader.pm',
'Data/Dumper.pm' => '/usr/lib64/perl5/vendor_perl/Data/Dumper.pm',
'feature.pm' => '/usr/share/perl5/feature.pm'
};
更新:实际上,这是一种更简单的方法。
$ perldoc -lm Your::Module