Perl: error message: can´t locate … in @INC


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

Can't locate Email/ 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/ line 9.
BEGIN failed–compilation aborted at C:/strawberry/perl/lib/Regexp/Common/Email/ line 9.
Compilation failed in require at (eval 1) line 1.
BEGIN failed–compilation aborted at C:\examples\ line 4.

I don´t understand because I really have this root


Does anybody know why I have this error message when I try to compilate my scrip?

Thank you so much

I tried to use this sentence:

use lib 'C:/strawberry/perl/lib/Regexp/Common/Email';

and putting as comment these two sentences:

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

then I get this error

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

I´ve taken a look at 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 "::").

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

I get this code from a question I asked before.

Best Solution

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/

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

Update with a bit more explanation:

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, but they would represent very different concepts. They would be distinguished from each other by their paths in your module library.

Related Question