tags:

views:

156

answers:

4

I tried running:

perl -e "use Error;" 

from cmd in windows 7. (active perl 5.12 installed on system) and I am getting the error

Can't locate Error.pm in @INC (@INC contains: C:/Perl64/site/lib C:/Perl64/lib )

I manually searched and found Error.pm in C:/Perl64/lib/CPANPLUS.

Does anyone have an idea what could be going on here?

A: 

Error.pm is not found because it is not directly under any of the directories listed in @INC. Add C:/Perl64/lib/CPANPLUS to @INC. Here is one way:

perl -IC:/Perl64/lib/CPANPLUS -e "use Error;" 

For other methods, see How do I add a directory to my include path (@INC) at runtime? from perlfaq8.

As a side note, the Error POD states:

Using the "Error" module is no longer recommended

toolic
I suppose this could work, but shouldn't there be a switch I can set so that the perl compiler will recursively search the module library directories? I was really hoping for an answer along those lines...
chuck taylor
perl does not work that way.
toolic
you could set PERL5LIB to prepend a directory to @INC also to see your @INC perl -V
xenoterracide
Don't modify PERL5LIB or @INC w/o REALLY thinking it through. That can land you in a boatload of trouble.Perl doesn't do recursive names because modules must be fully named. For example, there may be a half dozen modules called Copy.pm which are sub-modules to other modules. (Some I can think of right off hand are `File::Rotate::Backup::Copy` and `File::Copy`. The modularization of Perl is part of its OOP structure. You see similar style in Java, Objective C, and Python where modules must be fully named. BTW, All Perl programmers should learn Programming in OOP.
David W.
A: 

you could set PERL5LIB to prepend a directory to @INC

PERL5LIB="C:/Perl64/lib/CPANPLUS"

I forget how to set env variables permanently in windows (or if this is even the right syntax for the shell.)

also to see your @INC perl -V

xenoterracide
+1  A: 

You have to install the module Error that can be found on CPAN. But be aware of this warning:

Using the "Error" module is no longer recommended due to the black-magical nature of its syntactic sugar, which often tends to break. Its maintainers have stopped actively writing code that uses it, and discourage people from doing so. See the "SEE ALSO" section below for better recommendations.

M42
Why the downvotes ?
M42
+1  A: 

lib/CPANPLUS/Error.pm is a core "CPANPLUS::Error" module. It is used by CPANPLUS. If you want to use non-core "Error" module, you need to install it. Do "ppm install Error". Also, you can use similar modules Try::Tiny and TryCatch. They are non-core too, so you also would need to install them.

Alexandr Ciornii