Pet*_*one 3 perl compiler-errors
我正在尝试编译这个脚本,但我有这样的信息:
无法在C中找到@INC中的Email/Address.pm(@INC包含:C:/ strawberry/perl/lib C:/ strawberry/perl/site/lib C:\ strawberry\perl\vendor\lib.):/strawberry/perl/lib/Regexp/Common/Email/Address.pm第9行.BEGIN失败 - 编译在C:/ strawberry/perl/lib/Regexp/Common/Email/Address.pm第9行中止.编译失败需要在(eval 1)第1行.BEGIN失败 - 编译在C:\ examples\script2.pl第4行中止.
我不明白,因为我真的有这个根
C:/strawberry/perl/lib/Regexp/Common/Email/Address.pm
有人在我尝试编写我的脚本时知道为什么会出现此错误消息吗?
非常感谢
我试着用这句话:
使用lib'C:/ strawberry/perl/lib/Regexp/Common/Email';
并将这两句话作为评论:
use Regexp::Common qw[Email::Address];
use Email::Address
Run Code Online (Sandbox Code Playgroud)
然后我收到这个错误
Global symbol "%RE" requires explicit package name at C:\examples\script2.pl lin
e 10.Execution of C:\examples\script2.pl aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)
我看了一下perldiag
全局符号"%s"需要显式包名(F)您说过"use strict"或"use strict vars",表示所有变量必须是词法范围(使用"my"或"state"),声明预先使用"我们的",或明确限定说明全局变量所在的包(使用"::").
但我发现它对我来说有点理论上我明白你必须在代码的乞讨时使用句子'use'来使用包.
顺便说一下这是我的代码:
use Regexp::Common qw[Email::Address];
use Email::Address;
while (<>) {
my (@found) = /($RE{Email}{Address})/g;
my (@addrs) = map $_->address, Email::Address->parse("@found");
print "X-Addresses: ", join(", ", @addrs), "\n";
}
Run Code Online (Sandbox Code Playgroud)
dan*_*111 11
我认为问题是,你确实Regexp::Common::Email::Address安装了.但是,您还需要Email::Address,这是一个单独的模块.也就是说,你也应该安装一个模块C:/strawberry/perl/lib/Email/Address.pm.
尝试使用cpan进行安装Email::Address,请参阅安装缺少的Perl模块的最简单方法是什么?
更新一点解释:
Perl模块以分层方式组织.该::包分离等于在你的模块库路径的目录.模块的全名/含义源自包本身的名称和安装它的路径.假设你已经模块调用Restaurant::Bill,Hat::Bill以及Names::Male::Bill.您将调用三个不同的文件Bill.pm,但它们代表了截然不同的概念.它们将通过模块库中的路径彼此区分.