2012-03-07 74 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 => {