Ken Ken - 1 year ago 60
Perl Question

Can't locate in @INC

I have a Perl app on my development server that I would like to replicate on my local machine (mac osx). I'm not a perl programmer by trade (I'm a PHP/Rails developer), and the developer of this app is no longer around so I can't contact him for help. I've gotten pretty close to getting it to work. I was able to install all the packages using CPAN (at least I think I got them all) but I keep running into the following error:

Can't locate WebCNP/ in @INC (
@INC contains: /Library/Perl/5.16/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.16 .
at line 30.

On the server, the app's file structure looks like this:

/var/www/cgi-bin (empty dir)
/var/www/html (empty dir)
/var/www/perl (the config file is located in this directory)
- /WebCNP/
/var/www/ssi (all the .pl files for the app are located here, including all the JS and CSS files)

Line 30 of
has the following:

use WebCNP::Config;

Any ideas what I could be doing wrong?

Just so you know I've copied the file structure of the app from my development server to my local machine and created a virtual host so that it points to the app's root directory (/var/www).

Thanks in advanced for any insight!

Answer Source

was able to fix this with a symbolic link

ln -s /path/to/my/app/WebCNP /Library/Perl/5.16/WebCNP

I take this isn't a module from CPAN.

I would be a bit hesitant to use a symbolic link. This will work, but you're basically linking in a file you have under your own control to the master /Library directory on MacOS X. You delete your file, and that link won't be pointing to anything.

You can use use lib to add directories that contain your modules to the @INC directory:

use lib qw(/path/to/my/app);

This will now include this path for module searches.

If you rather install the module itself, why not simply copy it into /Lbrary/Perl/5.16 itself? It's what cpan would have done. At least this way, you're Perl module directory isn't dependent upon a link that can be removed.