I am using ActiveState perl with Komodo Edit. I am getting the following error.
Can't locate MyGengo.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at D:\oDesk\MyGengo Integration\sample line 6.
Why is the interpreter looking in C:/Perl/lib
instead of C:\Perl\lib
?
Doesn’t it know that it is Windows and not Linux?
EDIT
I resolved the problem by copying the .pm
file in C:\Perl\lib
directory. I think, the issue happened since this module was manually downloaded. PPM install would copy the .pm
file to the lib
directory.
As far as Windows is concerned,
C:/Perl/lib
andC:\Perl\lib
are the same directory.The perlport documentation notes (emphasis added)
Your comment shows that you’re using mygengo-perl-new but have it installed in
C:\Perl\lib\MyGengo\mygengo-api\nheinric-mygengo-perl-new-ce194df\mygengo
. This is an unusual location to install the module. The way the module is written, it expectsmygengo.pm
to be in one of the directories named in@INC
. Client code then pulls it in withMy suggestion is to move
mygengo.pm
fromC:\Perl\lib\MyGengo\mygengo-api\nheinric-mygengo-perl-new-ce194df\mygengo
toC:\Perl\site\lib
.As an alternative if you are using mygengo as part of another package that you’re developing, you could drop
mygengo
in your source tree, perhaps as a git submodule. Don’t forget to adduse lib 'mygengo';
if you do it this way.For full details, read about the
@INC
search process in the perlfunc documentation onrequire
and the extra semantics for modules viause
.General advice on slashes versus backslashes
Even if your code will run on Windows only, prefer using forward-slash as the separator in hardcoded paths. Backslash is an escape character in the Perl language, so you have to think more carefully about it. In double-quoted strings, you have to remember to escape the escape character to get its ordinary meaning, e.g.,
The situation can be a little nicer inside single-quoted strings. Setting
$dir
as indoes what you expect, but say you want
$dir
to have a trailing slash.Now you have a syntax error.
You may want to interpolate another value into
$dir
.Oh yeah, you need double-quotes for interpolation.
After headscratching and debugging
Backslash is therefore more mistake-prone and a maintenance irritant. Forward slash is an ordinary character inside both single- and double-quoted strings, so it almost always means what you expect.
As perlport notes, the Windows command shell treats forward slash as introducing options and backslash as path separators. If you cannot avoid the shell, then you may be forced to deal with backslashes.