2012-03-07 48 views
3

安装Perl的DateTime时,出现以下错误,并且失败;安装Perl日期时间

# Failed test 'Make sure we can add 50 years worth of years in America/New_York time zone' 
# at t/30future-tz.t line 45. 
Use of uninitialized value in numeric ge (>=) at /home/bensley/.cpan/build/DateTime-0.72/blib/lib/DateTime.pm line 138. 

# Failed test 'Make sure we can add 50 years worth of days in America/Chicago time zone' 
# at t/30future-tz.t line 45. 
Use of uninitialized value in numeric ge (>=) at /home/bensley/.cpan/build/DateTime-0.72/blib/lib/DateTime.pm line 138. 

# Failed test 'Make sure we can add 50 years worth of minutes in America/Denver time zone' 
# at t/30future-tz.t line 45. 
Use of uninitialized value in numeric ge (>=) at /home/bensley/.cpan/build/DateTime-0.72/blib/lib/DateTime.pm line 138. 

# Failed test 'Make sure we can add 50 years worth of seconds in America/Los_Angeles time zone' 
# at t/30future-tz.t line 45. 
Use of uninitialized value in numeric ge (>=) at /home/bensley/.cpan/build/DateTime-0.72/blib/lib/DateTime.pm line 138. 

# Failed test 'Make sure we can add 50 years worth of nanoseconds in America/North_Dakota/Center time zone' 
# at t/30future-tz.t line 45. 

完整的输出相当长,所以我在这里贴吧:http://pastebin.com/raw.php?i=JiJeH4ij

我是新来的Perl模块正是如此,完全丧失。这里发生了什么?

UPDATE:

$ perl --version 

This is perl, v5.8.8 built for i486-linux-gnu-thread-multi 

$ lsb_release -a 
No LSB modules are available. 
Distributor ID: Ubuntu 
Description: Ubuntu 8.04.4 LTS 
Release: 8.04 
Codename: hardy 
+0

您使用的是32位位或64位Perl?你使用的是哪个版本的Perl?在哪个平台上? – 2012-03-07 12:30:12

+0

对不起,我的错误,我已更新该帖子。谢谢你的推动! – jwbensley 2012-03-07 12:36:31

+0

这不完全是Perl ...和32位的最新版本。嗯......我在Mac OS X 10.7.3上有一个64位的Perl 5.14.1,我只是重新编译和测试DateTime 0.72而没有任何问题。我有一个32位的Perl 5.10.0可以玩 - 我需要升级它的模块,尽管(自从我上次使用它以来,并且'Build'支持太旧了,看起来好像有一段时间了。 – 2012-03-07 12:42:30

回答

9

这可能是你的问题。

Package seems to come without Makefile.PL. 
    (The test -f "/home/bensley/.cpan/build/DateTime-0.72/Makefile.PL" returned false.) 
    Writing one on our own (setting NAME to DateTime) 

您的CPAN客户端的副本是做出来不承认“新”(我指的是10岁)Build.PL模块装配及安装机制日期。 CPAN改为编写自己的安装程序,并试图进行安装。这将适用于许多Perl模块,但它可能会错过DateTime所要求的一些微妙之处。

升级CPAN客户端,您可以使用CPAN客户端,然后重试。

+0

我相信我已经正确更新CPAN,而我目前的版本是1.9800。这听起来像我正在查看正确的版本号? :)尽管如此,仍然不能安装DateTime。 – jwbensley 2012-03-08 15:47:01

+0

我现在更新了Perl到5.14,DateTime已经安装到了0.72,这非常棒。我仍然无法安装我的应用程序,它抛出了有关“DateTime> = 0.44 ... MISSING”的错误,但这是另一个问题。运行“cpan DateTime”确认我更新0.72。谢谢:) – jwbensley 2012-03-08 16:31:10

+0

@javano你的应用程序可能使用不同的perl副本或不同的'PERL5LIB'设置,而不是命令行上的设置,并且看不到已安装的库。我会问,作为一个单独的问题。 – Schwern 2012-03-08 17:42:15

2

线程死灵的道歉。

我有/有同样的问题,安装在Centos 5.7,perl 5.8.8(perl-5.8.8-38.el5)上。 令人讨厌的是,我的浏览器窗口与Devel :: Peek Dump()一起整个堆更多的细节。

只需说m/^ \ d + $/regex将pPOK(与POKp?相同)标志关闭,并且$ _ [0]在字符串和数字上下文中都变为undef。我认为这是在这个特定版本的Perl中的错误,因为我无法在其他操作系统上重现。

我最终改变DateTime.pm避免这个问题,因为更新Perl是不是真的在此刻一个选项:

129c129 
<     sub { $_[0] =~ /^\d+$/ && $_[0] >= 1 && $_[0] <= 12 } 
--- 
>     sub { $_[0] && $_[0] !~ /\D/ && $_[0] >= 1 && $_[0] <= 12 } 
137c137 
<     sub { $_[0] =~ m/^\d+$/ && $_[0] >=1 && $_[0] <= 31 } 
--- 
>     sub { $_[0] && $_[0] !~ m/\D/ && $_[0] >=1 && $_[0] <= 31 } 

编辑:发现杰韦利::皮克东西在我的缓冲区。

# generated by having this inside the validation sub 
warn("before re (" . $_[0]. ")"); 
Dump($_[0]) 
return unless $_[0] =~ s/^\d+$/; 
warn("after re (" . $_[0] . ")"); 
Dump($_[0]); 

输出:

before re (1) at blib/lib/DateTime.pm line 139. 
SV = PVMG(0x8104d40) at 0x827dc24 
REFCNT = 7 
FLAGS = (GMG,SMG,READONLY,pPOK) 
IV = 0 
NV = 0 
PV = 0x8502610 "1"\0 
CUR = 1 
LEN = 4 
MAGIC = 0x82d9a30 
    MG_VIRTUAL = &PL_vtbl_sv 
    MG_TYPE = PERL_MAGIC_sv(\0) 
    MG_OBJ = 0x827dc18 
    MG_LEN = 1 
    MG_PTR = 0x82d9a50 "3" 
Use of uninitialized value in concatenation (.) or string at blib/lib/DateTime.pm line 142. 
after re() at blib/lib/DateTime.pm line 142. 
SV = PVMG(0x8104d40) at 0x827dc24 
REFCNT = 7 
FLAGS = (GMG,SMG,READONLY) 
IV = 0 
NV = 0 
PV = 0x8502610 "1"\0 
CUR = 1 
LEN = 4 
MAGIC = 0x82d9a30 
    MG_VIRTUAL = &PL_vtbl_sv 
    MG_TYPE = PERL_MAGIC_sv(\0) 
    MG_OBJ = 0x827dc18 
    MG_LEN = 1 
    MG_PTR = 0x82d9a50 "3" 
Use of uninitialized value in numeric ge (>=) at blib/lib/DateTime.pm line 144. 
not ok 1 - Make sure we can add 50 years worth of years in America/New_York time zone 
# Failed test 'Make sure we can add 50 years worth of years in America/New_York time zone' 
# at t/30future-tz.t line 45. 
2

使用变量的副本合作解决该问题(perl的5.8.8,CentOS的5)...

diff -ur DateTime-0.76/lib/DateTime.pm DateTime-0.76--perl-5.8.8.fix/lib/DateTime.pm 
--- DateTime-0.76/lib/DateTime.pm.orig  2012-07-01 11:55:52.000000000 -1000 
+++ DateTime-0.76/lib/DateTime.pm 2013-03-25 11:10:26.209878929 -1000 
@@ -115,10 +115,17 @@ 
__PACKAGE__->DefaultLocale('en_US'); 

my $BasicValidate = { 
+ 
+# XXX Mar 25 2013. Test t/30future-tz.t fails in versions 0.7[68], with perl 
+# 5.8.8, with "Use of uninitialized value in numeric ge (>=) at [...] line 137." 
+# See http://stackoverflow.com/questions/9601516/installing-perl-datetime for 
+# other details. Apparently making a copy overcomes the problem of value 
+# changing to undef (discovered by trial-and-error). 
+ 
    year => { 
     type  => SCALAR, 
     callbacks => { 
-   'is an integer' => sub { $_[0] =~ /^-?\d+$/ } 
+   'is an integer' => sub { my $i = $_[0]; $i =~ /^-?\d+$/ } 
     }, 
    }, 
    month => { 
@@ -126,7 +133,7 @@ 
     default => 1, 
     callbacks => { 
      'an integer between 1 and 12' => 
-    sub { $_[0] =~ /^\d+$/ && $_[0] >= 1 && $_[0] <= 12 } 
+    sub { my $i = $_[0]; $i =~ /^\d+$/ && $i >= 1 && $i <= 12 } 
     }, 
    }, 
    day => { 
@@ -134,7 +141,7 @@ 
     default => 1, 
     callbacks => { 
      'an integer which is a possible valid day of month' => 
-    sub { $_[0] =~ /^\d+$/ && $_[0] >= 1 && $_[0] <= 31 } 
+    sub { my $i = $_[0]; $i =~ /^\d+$/ && $i >= 1 && $i <= 31 } 
     }, 
    }, 
    hour => { 
@@ -142,7 +149,7 @@ 
     default => 0, 
     callbacks => { 
      'an integer between 0 and 23' => 
-    sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 23 }, 
+    sub { my $i = $_[0]; $i =~ /^\d+$/ && $i >= 0 && $i <= 23 }, 
     }, 
    }, 
    minute => { 
@@ -150,7 +157,7 @@ 
     default => 0, 
     callbacks => { 
      'an integer between 0 and 59' => 
-    sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 59 }, 
+    sub { my $i = $_[0]; $i =~ /^\d+$/ && $i >= 0 && $i <= 59 }, 
     }, 
    }, 
    second => { 
@@ -158,14 +165,14 @@ 
     default => 0, 
     callbacks => { 
      'an integer between 0 and 61' => 
-    sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 61 }, 
+    sub { my $i = $_[0]; $i =~ /^\d+$/ && $i >= 0 && $i <= 61 }, 
     }, 
    }, 
    nanosecond => { 
     type  => SCALAR, 
     default => 0, 
     callbacks => { 
-   'a positive integer' => sub { $_[0] =~ /^\d+$/ && $_[0] >= 0 }, 
+   'a positive integer' => sub { my $i = $_[0]; $i =~ /^\d+$/ && $i >= 0 }, 
     } 
    }, 
    locale => {