本文介绍了Perl:错误消息:无法在@INC 中找到 ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编译这个脚本,但我有这样的消息:

I am trying to compilate this scrip, but I have this message:

在@INC 中找不到 Email/Address.pm(@INC 包含:C:/strawberry/perl/lib C:/草莓/perl/site/lib C:strawberryperlvendorlib .) 在 C:/strawberry/perl/lib/Regexp/Common/Email/Address.pm 第 9 行.BEGIN 失败——编译在 C:/strawberry/perl/lib/Regexp/Common/Email/中止地址.pm 第 9 行.在 (eval 1) 第 1 行的 require 中编译失败.BEGIN 失败——编译在 C:examplesscript2.pl 第 4 行中止.

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

I don´t understand because I really have this root

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

有人知道为什么我在编译我的脚本时会出现这个错误信息吗?

非常感谢

我试着用这句话:

使用 lib 'C:/strawberry/perl/lib/Regexp/Common/Email';

并将这两句话作为注释:

and putting as comment these two sentences:

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

然后我收到此错误

Global symbol "%RE" requires explicit package name at C:examplesscript2.pl lin
e 10.Execution of C:examplesscript2.pl aborted due to compilation errors.

我看过perldiag

全局符号%s"需要明确的包名(F) 您已经说过use strict"或use strict vars",这表明所有变量必须是词法范围的(使用my"或state"),使用our"预先声明,或者明确限定为说出全局变量在哪个包中(使用::").

但我觉得这对我来说有点理论化,因为我知道你必须在代码的乞求中使用句子使用"来使用包.

but I find it a little theoretical for me by I understand that you have to use packages by using the sentence 'use' at the begging of the code.

顺便说一下,这是我的代码:

By the way this is my code:

 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), "
";
  }

我从我之前问过的一个问题中获得了这个代码.

I get this code from a question I asked before.

推荐答案

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

I think the issue is, you do have Regexp::Common::Email::Address installed. However, you also need Email::Address, which is a separate module. That is to say, you should also have a module installed in C:/strawberry/perl/lib/Email/Address.pm.

尝试使用 cpan 安装 Email::Address,参见 安装缺少的 Perl 模块的最简单方法是什么?

Try using cpan to install Email::Address, see What's the easiest way to install a missing Perl module?

更新一点解释:

Perl 模块以分层方式组织.:: 包分隔符等于模块库路径中的一个目录.模块的全名/含义源自包本身的名称和安装路径.假设您有名为 Restaurant::BillHat::BillNames::Male::Bill 的模块.您将拥有三个名为 Bill.pm 的不同文件,但它们代表非常不同的概念.它们将通过它们在您的模块库中的路径来区分.

Perl modules are organized in a hierarchical manner. The :: package separator is equal to a directory in your module library path. The full name/meaning of the module is derived from both the name of the package itself and the path in which it is installed. Suppose you had modules called Restaurant::Bill, Hat::Bill, and Names::Male::Bill. You would have three different files called Bill.pm, but they would represent very different concepts. They would be distinguished from each other by their paths in your module library.

这篇关于Perl:错误消息:无法在@INC 中找到 ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 02:30