Perl模块导入错误

时间:2017-07-21 01:41:59

标签: mongodb perl perl-module

我安装了MongoDB perl模块。

我有一个简单的perl脚本(下面):

 use MongoDB ();
 print "OK!\n";

当我编译这个perl脚本时,我收到以下错误:

"all" is not exported by the List::Util module
Can't continue after import errors at /usr/local/share/perl5/Specio/OO.pm 
line 9
BEGIN failed--compilation aborted at /usr/local/share/perl5/Specio/OO.pm 
line 9.
Compilation failed in require at /usr/local/share/perl5/Specio/Coercion.pm 
line 8.
BEGIN failed--compilation aborted at 
/usr/local/share/perl5/Specio/Coercion.pm line 8.
Compilation failed in require at /usr/local/share/perl5/Specio/Declare.pm 
line 11.
BEGIN failed--compilation aborted at 
/usr/local/share/perl5/Specio/Declare.pm line 11.
Compilation failed in require at /usr/local/lib64/perl5/DateTime/Types.pm 
line 12.
BEGIN failed--compilation aborted at 
/usr/local/lib64/perl5/DateTime/Types.pm line 12.
Compilation failed in require at /usr/local/lib64/perl5/DateTime/Duration.pm 
line 12.
BEGIN failed--compilation aborted at 
/usr/local/lib64/perl5/DateTime/Duration.pm line 12.
Compilation failed in require at /usr/local/lib64/perl5/DateTime.pm line 14.
BEGIN failed--compilation aborted at /usr/local/lib64/perl5/DateTime.pm line 
14.
Compilation failed in require at /usr/local/lib64/perl5/MongoDB/BSON.pm line 
35.
BEGIN failed--compilation aborted at /usr/local/lib64/perl5/MongoDB/BSON.pm 
line 35.
Compilation failed in require at /usr/local/lib64/perl5/MongoDB.pm line 32.
BEGIN failed--compilation aborted at /usr/local/lib64/perl5/MongoDB.pm line 
32.
Compilation failed in require at script.pl line 2.
BEGIN failed--compilation aborted at script.pl line 2.

/usr/local/share/perl5/Specio/OO.pm 第9行,有以下使用声明。

use List::Util qw( all );

我相信上面的行是所有错误的原因,因为它们似乎是嵌套在这个文件中。

如何解决此错误?

1 个答案:

答案 0 :(得分:-1)

可能存在递归调用导出例程 qw(all) 的模块。

/usr/local/share/perl5/Specio/OO.pm 第 9 行调用以下导出的方法:

use List::Util qw( all );

这个方法也可以被第 2 行 script.pl 中使用的模块调用。

Compilation failed in require at script.pl line 2.

在代码块中使用 require 代替使用 List::Util qw( all );在 script.pl 第 2 行的给定模块中,仅在需要的地方。

这可能会解决您面临的问题。