2

我正在清理代码并Forecast::IO从我的 Perl 脚本中删除现在已弃用的模块。当我这样做时,我开始收到此错误:

[root@server cgi-bin]# perl Weather.pm
Undefined subroutine &B::perlstring called at /usr/local/share/perl5/Params/ValidationCompiler/Compiler.pm line 248.
Compilation failed in require at /usr/local/lib64/perl5/DateTime.pm line 13.
BEGIN failed--compilation aborted at /usr/local/lib64/perl5/DateTime.pm line 13.
Compilation failed in require at Weather.pm line 1340.
BEGIN failed--compilation aborted at Weather.pm line 1340.

发生错误的第 1340 行是无害的,use DateTime;.

我不确定是什么DateTime会导致它不高兴我不再使用不相关的Forecast::IO模块,所以我开始拆开后一个模块以找出阻止错误的代码。基本部分似乎Moo包含在其中,Forecast::IO并且至少有一个 Moohas声明:

package Forecast::IO;
use Moo;
has testkey => ( is => 'ro' ); 
1;

出于某种原因,如果存在至少具有这些行的模块,则 DateTime 加载正常。否则,会发生我上面提到的错误,在 DateTime 的第 13 行阻塞use Carp;。即使我放入use Moo; has testkey => ( is => 'ro' );自己的模块,它也会在use DateTime.

即使我曾经grep -r Forecast::IO遍历代码库以寻找一些错误的引用并出现空缺。所以,我决定尝试加载 DateTime 模块:perl -MDateTime. 这也会产生错误:

[root@server cgi-bin]# perl -MDateTime
Undefined subroutine &B::perlstring called at     /usr/local/share/perl5/Params/ValidationCompiler/Compiler.pm line 248.
Compilation failed in require at /usr/local/lib64/perl5/DateTime.pm line 13.
BEGIN failed--compilation aborted at /usr/local/lib64/perl5/DateTime.pm line 13.
Compilation failed in require.
BEGIN failed--compilation aborted.
4

0 回答 0