【问题标题】:Isn't List::Util part of Standard Perl Distribution?List::Util 不是标准 Perl 发行版的一部分吗?
【发布时间】:2012-01-01 18:14:00
【问题描述】:

在某个系统上,我正在运行一个 perl 脚本,但它失败了

Can't locate List/Util.pm in @INC (@INC contains: <Some-Path>/ActiveState/perl/lib <Some-Path>/ActiveState/perl/site/lib .) at <Some-Other-Path>\searchCobolPgms.ps line 7.

现在奇怪的是,在将代码部署到故障系统之前,我在笔记本电脑上运行它,它运行良好。这两个系统的不同之处在于,在我的笔记本电脑中,我使用的是 Cygwin,并且捆绑了 perl,并且所述故障系统具有 ActiveState perl

<Some-Path>perl -v

This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 635 provided by ActiveState Corp. http://www.ActiveState.com
Built 15:34:21 Feb  4 2003


Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.

然后我在 cygwin 的库下搜索 Util,它存在于 i686-cygwin 下

c:\cygwin\lib\perl5\5.10>find . -name Util.pm
./CGI/Util.pm
./i686-cygwin/Hash/Util.pm
./i686-cygwin/List/Util.pm
./i686-cygwin/Scalar/Util.pm

所以现在我很困惑。不是;t List::Util 标准 perl 发行版的一部分吗? 我困惑的原因

  1. List/Util.pm 存在于 i686-cygwin 下
  2. ActiveSync 安装没有 List/Util.pm

【问题讨论】:

  • 我怀疑你使用的 perl 的旧版本不包括它。它并不总是核心库的一部分。
  • @BrianRoach,是的,您的猜测是正确的。这就是问题所在。
  • Perl 5.6.1 已经十多年了。请更新到最新的内容。我推荐草莓 Perl - strawberryperl.com

标签: perl list cygwin activestate


【解决方案1】:

List::Util 仅在 5.7(开发版本)中添加到核心中,包含 List::Util 的 perl 的第一个稳定版本是 5.8.0。因此,虽然它位于您在 cygwin 下安装的 perl 5.10 发行版中,但您调用的 perl 5.6.1 ActiveState 可执行文件没有它。您应该将 ActiveState perl 更新到至少 5.8.0,然后它将拥有您需要的模块。

这里有一个链接可以找到包含核心模块的所有 perl 版本:http://perlpunks.de/corelist/version?module=List%3A%3AUtil

【讨论】:

  • 谢谢。这对我来说很有意义。不幸的是,我不能那么容易地更新 ActiveState perl,因为这意味着除了整个认证链 bla bla 之外,我还必须进行整个法律和版权工作。所以这意味着我最终必须更改我的脚本以不使用 List::Util。再次感谢特别是链接:-)
  • 好吧,你也可以只安装 List::Util 而不更新 ActiveState。在 CPAN 上的 1.23_03 版本中有一个名为 Scalar-List-Utils 的包,它似乎与 perl 5.6 兼容,自述文件中列出了一个警告:cpansearch.perl.org/src/GBARR/Scalar-List-Utils-1.23_03/README - 至少它是你需要的少量东西通过您的法律部门:)
  • 你也没有理由找不到一个真正旧版本的 List::Util,它打算安装在 perl 5.6 上。 List::Util 1.06_00 是添加到核心的版本,所以在此之前的任何东西都打算安装在 perl 5.6 上。您可以在 backpan.perl.org/authors/id/G/GB/GBARR 从 BackPAN 获取所有版本的软件包
【解决方案2】:

当我查看corelist 时,我得到:

corelist List::Util
List::Util was first released with perl v5.7.3

您的 perl 版本似乎是 5.6.1,在这种情况下,List::Util 不会成为核心安装的一部分。

c:\cygwin\lib\perl5\5.10 的路径来看,您的cygwin 版本似乎至少为5.10,但您会注意到,cygwin 路径不在您其他perl 版本的@INC 中。它们很可能是单独的安装,因此它们不共享库。

更新您的 ActiveState perl,一切都会好起来的。

【讨论】:

  • 感谢 TLP。当然,现在这对我来说很有意义。我刚刚从 DAN 获得了链接,这将帮助我进行兼容性编码:-)
猜你喜欢
  • 2017-04-11
  • 2011-01-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-11
相关资源
最近更新 更多