【问题标题】:Installing perl switch using CPAN is failing使用 CPAN 安装 perl 交换机失败
【发布时间】:2015-09-28 22:50:34
【问题描述】:

我将输出粘贴在下面(最初发布到http://pastebin.com/Sh7a8tHK

cpan[1]> install Switch
Reading '/.cpan/Metadata'
Database was generated on Tue, 11 Dec 2012 05:55:05 GMT
Running install for module 'Switch'
Running make for R/RG/RGARCIA/Switch-2.16.tar.gz
Checksum for /.cpan/sources/authors/id/R/RG/RGARCIA/Switch-2.16.tar.gz ok
Scanning cache /.cpan/build for sizes
............................................................................DONE

CPAN.pm: Building R/RG/RGARCIA/Switch-2.16.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Switch
Writing MYMETA.yml and MYMETA.json
cp Switch.pm blib/lib/Switch.pm
Manifying blib/man3/Switch.3
RGARCIA/Switch-2.16.tar.gz
/usr/ccs/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /opt/perl/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/given.t ... Useless use of numeric gt (>) in void context at t/given.t line 19.
t/given.t ... Failed 2/293 subtests
t/nested.t .. ok
t/switch.t .. ok

Test Summary Report
-------------------
t/given.t (Wstat: 0 Tests: 293 Failed: 2)
Failed tests:  2-3
Files=3, Tests=590,  1 wallclock secs ( 0.07 usr  0.01 sys +  0.47 cusr  0.00 csys =  0.55 CPU)
Result: FAIL
Failed 1/3 test programs. 2/590 subtests failed.
*** Error code 255
make: Fatal error: Command failed for target `test_dynamic'
RGARCIA/Switch-2.16.tar.gz
/usr/ccs/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports RGARCIA/Switch-2.16.tar.gz
Running make install
make test had returned bad status, won't install without force
Failed during this command:
RGARCIA/Switch-2.16.tar.gz                   : make_test NO

cpan[2]>

模块似乎存在问题,“无用使用数字 gt.....”证明了这一点,但是我使用 CPAN 在另一台机器上很好地安装了这个模块。这是 CPAN 在安装时抱怨的唯一模块。

我使用的是最新版本的 perl 5.16:

This is perl 5, version 16, subversion 2 (v5.16.2) built for i86pc-solaris

如何安装这个模块?

注意:请不要告诉我 Switch 已弃用。我明白了。

【问题讨论】:

  • 请不要使用 pastebin。如果文本在 pastebin 中,那么未来的用户将无法根据您报告的错误找到此问题。

标签: perl cpan


【解决方案1】:

尝试这样做:

use feature qw/switch/;

perldoc -q switch

【讨论】:

  • 既然现在内置了 switch (given\when),为什么我必须使用功能 qw/switch/;?无论哪种方式都有效。谢谢。
  • 为了向后兼容。如果它一直处于开启状态,它会破坏现有程序与名为 givenwhen 的子程序。
  • use 5.010 也会自动启用given/when
【解决方案2】:

如果您可以使用 Perl v5.10 或更高版本,请参阅 The Effective Perler 文章 Use for() instead of given()

【讨论】:

  • 在 5.018 中,given 将像 for 一样使用别名。
【解决方案3】:

补丁:

--- Switch-2.16-wjgfvU/Switch.pm 2009-10-23 00:52:51.000000000 -0700

+++ Switch-2.16-wjgfvUcopy/Switch.pm 2010-08-15 17:41:38.000000000 -0700

@@ -146,7 +146,7 @@ sub filter_blocks
die "Bad $keyword statement (problem in the code block?) near $Switch::file line ", line(substr($source,0, pos $source), $line), "\n";
        };
my $code = filter_blocks(substr($source,$pos[0],$pos[4]-$pos[0]),line(substr($source,0,$pos[0]),$line));
-           $code =~ s/{/{ local \$::_S_W_I_T_C_H; Switch::switch $arg;/;
+           $code =~ s/{/{ local \$::_S_W_I_T_C_H; Switch::switch($arg);/;
            $text .= $code . 'continue {last}';
            next component;
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-01
    • 1970-01-01
    • 2013-06-16
    • 2013-11-07
    • 2018-06-19
    • 2014-02-01
    • 2013-11-04
    • 1970-01-01
    相关资源
    最近更新 更多