Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
安装Perl日期时间_Perl_Perl Module - Fatal编程技术网

安装Perl日期时间

安装Perl日期时间,perl,perl-module,Perl,Perl Module,在为Perl安装DateTime时,我遇到以下错误,但失败了 # 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/bl

在为Perl安装DateTime时,我遇到以下错误,但失败了

#   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.
完整输出相当长,因此我将其粘贴在此处:

我是Perl模块的新手,因此完全迷路了。这是怎么回事

更新:

$ 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

这可能是你的问题

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
module构建和安装机制。相反,CPAN编写了自己的安装程序,并尝试进行安装。这将适用于许多Perl模块,但它可能遗漏了DateTime所需的一些细节


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

为线程坏死术道歉

在Centos 5.7、perl 5.8.8(perl-5.8.8-38.el5)上安装时,我也遇到了同样的问题。 令人恼火的是,我的浏览器窗口崩溃了,有一大堆关于Devel::Peek Dump()的详细信息

可以说,m/^\d+$/regex关闭了pPOK(与POKp相同?)标志,并且$U[0]在字符串和数字上下文中都变为未定义。我假设这是这个特定版本的perl中的一个bug,因为我无法在其他操作系统上重现

我最终更改了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 }
输出:

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.

使用变量的副本解决了这个问题(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 @@
__软件包->默认语言环境('en_US');
我的$BasicValidate={
+
+#XXX 2013年3月25日。测试t/30TZ.t在版本0.7[68]中失败,使用perl
+#5.8.8,带有“在[…]行137使用未初始化的数值ge(>=)。”
+#看http://stackoverflow.com/questions/9601516/installing-perl-datetime 对于
+#其他细节。显然,复制可以克服价值问题
+#更改为未定义(通过尝试和错误发现)。
+
年份=>{
类型=>标量,
回调=>{
-'是一个整数'=>sub{$\[0]=~/^-?\d+$/}
+'是一个整数'=>sub{my$i=$\[0];$i=~/^-?\d+$/}
},
},
月份=>{
@@ -126,7 +133,7 @@
默认值=>1,
回调=>{
'介于1和12之间的整数'=>
-sub{$\[0]=~/^\d+$/&&$\[0]>=1&&$\[0]=1&&&$i{
@@ -134,7 +141,7 @@
默认值=>1,
回调=>{
'一个整数,可能是一个月的有效日期'=>
-sub{$\[0]=~/^\d+$/&&$\[0]>=1&&$\[0]=1&&&$i{
@@ -142,7 +149,7 @@
默认值=>0,
回调=>{
'介于0和23之间的整数'=>
-sub{$\[0]=~/^\d+$/&&$\[0]>=0&&$\[0]=0&&&$i{
@@ -150,7 +157,7 @@
默认值=>0,
回调=>{
'介于0和59之间的整数'=>
-sub{$\[0]=~/^\d+$/&&$\[0]>=0&&$\[0]=0&&&$i{
@@ -158,14 +165,14 @@
默认值=>0,
回调=>{
'介于0和61之间的整数'=>
-sub{$\[0]=~/^\d+$/&&$\[0]>=0&&$\[0]=0&&&$i{
类型=>标量,
默认值=>0,
回调=>{
-'正整数'=>sub{$\[0]=~/^\d+$/&&$\[0]>=0},
+“一个正整数”=>sub{my$i=$\[0];$i=~/^\d+$/&&$i>=0},
}
},
地区=>{

您使用的是32位还是64位的Perl?您使用的是哪个版本的Perl?在哪个平台上?对不起,我错了,我已经更新了帖子。感谢您的提醒!这不是Perl的最新版本…和32位的.Hmmm…我在Mac OS X 10.7.3上有一个64位的Perl 5.14.1,我只是重新运行了DateTime 0.72的构建和测试,而没有任何更改任何问题。我有一个32位的Perl 5.10.0要玩——不过我需要升级它的模块(我上次使用它已经有一段时间了,而且
构建
支持似乎太旧了)。我相信我已经正确地更新了CPAN,我当前的版本是1.9800。这听起来像是我看到了正确的版本号吗?:)但是仍然不能安装DateTime。我现在已经将Perl更新到5.14,DateTime已经安装到0.72,这很好。我仍然不能安装我的应用程序,这会引发一个错误“DateTime>=0.44…缺失”,但这是另一个问题。运行“cpan DateTime”确认我更新了0.72。谢谢:)@javano您的应用程序可能使用了不同于命令行的perl副本或不同的
PERL5LIB
设置,并且看不到已安装的库。我将作为单独的问题询问。
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.
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 => {