Can't access installed perl module

software development

#1

I think my CPAN module is in the right place, but I can’t get perl to find it.

The module in question is Captcha::AreYouAHuman, and it’s installed in
~/perlmods/shared/perl/5.10.1/Captcha/AreYouAHuman.pm

If I try to run my program, it aborts at the ‘use Captcha:AreYouAHuman;’ line, saying that it’s not in @INC.

On the advice of a more knowledgable aquaintance, I added the following lines to my program:

use lib “$ENV{HOME}/perlmods/lib/perl/5.10.1”;
use lib “$ENV{HOME}/perlmods/share/perl/5.10.1”;
use lib “$ENV{HOME}/perlmods/local/perl/5.10.1”;

Still no joy, but the newer error message did show those directories in @INC.

Finally, I tried calling by direct path:

require “/perlmods/share/perl/5.10.1/Captcha/AreYouAHuman.pm”;

This gets me this error message:
Can’t locate /perlmods/share/perl/5.10.1/Captcha/AreYouAHuman.pm in @INC (@INC contains: /perlmods/local/perl/5.10.1 /perlmods/share/perl/5.10.1/ /perlmods/lib/perl/5.10.1/ /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at ayah-test1.cgi line 10.

Help?

Thanks,
Kevin


#2

Your module is installed in ~/perlmods/shared/… but you you told perl to look in ~/perlmods/share/…


#3

Thanks, but that was my typo in the post – the ‘d’ wasn’t actually part of the dir name.

I did get it running. It appears that ‘$ENV{HOME}’ didn’t return the home directory – omitting it gave the same path names in the error message as including it.

After some experimentation, I found that what it should have been inserting was ‘/home/AccntName/’. I added that to my require path, and everything was hunky-dory.


#4

Excellent. That would have been by second guess, but I wasn’t sure how to do it in Perl. Bash would just be $HOME…


#5

For CGI scripts only certain environment variables are passed on by default from the web server, related to the web server and the request that was made. AFAIK you can only expect PATH to be carried over.