Perl:错误消息:无法在@INC中找到…

前端之家收集整理的这篇文章主要介绍了Perl:错误消息:无法在@INC中找到…前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试编译 this scrip,但我有这样的信息:

Can’t locate Email/Address.pm in @INC (@INC contains: C:/strawberry/perl/lib C:/
strawberry/perl/site/lib C:\strawberry\perl\vendor\lib .) at C:/strawberry/perl/
lib/Regexp/Common/Email/Address.pm line 9.
BEGIN Failed–compilation aborted at C:/strawberry/perl/lib/Regexp/Common/Email/
Address.pm line 9.
Compilation Failed in require at (eval 1) line 1.
BEGIN Failed–compilation aborted at C:\examples\script2.pl line 4.

我不明白,因为我真的有这个根

C:/strawberry/perl/lib/Regexp/Common/Email/Address.pm

有人在我尝试编写我的脚本时知道为什么会出现此错误消息吗?

非常感谢

我试着用这句话:

use lib ‘C:/strawberry/perl/lib/Regexp/Common/Email’;

并将这两句话作为评论

use Regexp::Common qw[Email::Address];
  use Email::Address

然后我收到这个错误

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.

我看过perldiag

Global symbol “%s” requires explicit package name
(F) You’ve said “use strict” or “use strict vars”,which indicates that all variables must either be lexically scoped (using “my” or “state”),declared beforehand using “our”,or explicitly qualified to say which package the global variable is in (using “::”).

但我发现它对我来说有点理论上我明白你必须在代码的乞讨时使用句子’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";
  }

我收到此代码from a question I asked before.

解决方法

我认为问题是,你确实安装了 Regexp::Common::Email::Address.但是,您还需要 Email::Address,这是一个单独的模块.也就是说,您还应该在C:/strawberry/perl/lib/Email/Address.pm中安装一个模块.

尝试使用cpan安装Email :: Address,请参阅What’s the easiest way to install a missing Perl module?

更新一点解释:

Perl模块以分层方式组织. :: package分隔符等于模块库路径中的目录.模块的全名/含义源自包本身的名称和安装它的路径.假设您有名为Restaurant :: Bill,Hat :: Bill和Names :: Male :: Bill的模块.你会有三个不同的文件叫做Bill.pm,但它们代表了截然不同的概念.它们将通过模块库中的路径彼此区分.

猜你在找的Perl相关文章