我正在尝试在使用 CentOS Linux 7 的计算机上运行 perl 脚本。我有 perl 5.36.1。该脚本使用一个名为 polymake 的程序,该程序有自己的 perl 副本。我无法修改那个 perl 副本。我可以使用 cpan 为我的 Perl 副本安装模块。
使用 cpan,我安装了模块 Algorithm::Combinatorics
$ cpanm Algorithm::Combinatorics
Algorithm::Combinatorics is up to date. (0.27)
在“~/perl5/lib/perl5/Algorithm”中,有一个名为“Combinatorics.pm”的文件。
当我运行以下代码时
#!/usr/bin/perl
use lib '~/perl5/lib/perl5/Algorithm';
use lib '~/perl5/lib/perl5/';
use Combinatorics;
我收到错误消息
Can't locate Combinatorics.pm in @INC (you may need to install the Combinatorics module)
(@INC contains: ~/perl5/lib/perl5/ ~/perl5/lib/perl5/Algorithm Polymake::Core::Application=ARRAY(0x3b5c670) /share/software/user/open/polymake/4.10/share/polymake/perllib [...])
当我对 List::Compare 模块做同样的事情时,我没有问题。
更新:
这是一个更简单的例子:我制作了一个名为perlscripttest.pl.
#!/usr/bin/perl
use strict;
use warnings;
use Algorithm::Combinatorics "subsets";
print(subsets[1,2,3,4]);
然后perl perlscripttest.pl
给出错误:
Can't locate loadable object for module Algorithm::Combinatorics in @INC
(@INC contains: /share/software/user/open/polymake/4.10/share/perl5/lib/perl5/x86_64-linux-thread-multi
/share/software/user/open/polymake/4.10/share/perl5/lib/perl5 /home/users/mwlarson/perl5/lib/perl5/x86_64-linux-thread-multi /home/users/mwlarson/perl5/lib/perl5
/share/software/user/open/perl/5.36.1/lib/site_perl/5.36.1/x86_64-linux-thread-multi
/share/software/user/open/perl/5.36.1/lib/site_perl/5.36.1
/share/software/user/open/perl/5.36.1/lib/5.36.1/x86_64-linux-thread-multi /share/software/user/open/perl/5.36.1/lib/5.36.1) at perlscripttest.pl line 6.
使用 List::Compare 执行相同的操作不会产生错误。