Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Can't locate module in @INC

by rpike (Scribe)
on Dec 09, 2009 at 14:48 UTC ( #811932=perlquestion: print w/replies, xml ) Need Help??

rpike has asked for the wisdom of the Perl Monks concerning the following question:

I'm not sure how it was done but on a server I'm working on it looks like there used to be a drive C that was changed to another letter and then a new C created. An older version of Perl (5.6) was installed in that older directory and it was where my scripts in the new directory were looking to find Perl (errors I was getting was saying can't find in @INC Y:/Perl/bin, etc.., and doing perl -e "print join('\n', @INC);" at command line was printing the old directory as well. I installed a new version of perl (5.10) off of activestate and now the error and prints at command line now shows the C drive in the paths but the module still isn't getting picked up in my Perl/CGI script. The script running and the modules "use"d are in the same directory (cgi-bin). Anyone know what else I can check or should change? Thanks in advance for any help.

Replies are listed 'Best First'.
Re: Can't locate module in @INC
by bv (Friar) on Dec 09, 2009 at 15:04 UTC

    Not sure how good of a solution this is, but to get you up and running, use lib


    @_=qw; Just another Perl hacker,; ;$_=q=print "@_"= and eval;
Re: Can't locate module in @INC
by cdarke (Prior) on Dec 09, 2009 at 15:18 UTC
    The script running and the modules "use"d are in the same directory (cgi-bin)

    But is cgi-bin in your @INC array? Just because the script is in the cgi-bin directory it does not mean that this is the current directory (.) - that depends on how the web server runs. Add the directory that your modules reside in into @INC, and there are many ways to do that, try use lib 'cgi-bin-full-path'; in your code, or set the environment variable PERL5LIB. Is it a good idea to put modules into cgi-bin?
      Right now the modules in cgi-bin bit doesn't bother me as much as having directories added to @INC outside the script (without having to use full paths). What are the various ways I can set the PERL5LIB environment variable? Are there ways to set it per session (reboot clears em) and a way to set it and have it remain persistent between reboots? Thanks for the posts guys.
Re: Can't locate module in @INC
by rpike (Scribe) on Dec 09, 2009 at 15:21 UTC
    I need it actually to be set up at the system level and not in code using use and the path (as I go I need everything working - don't ask :-)).
      use Cwd qw( realpath ); use File::Basename qw( dirname ); my $script_dir; BEGIN { $script_dir = dirname(realpath($0)); } use lib $script_dir;

      It's in your script, but nothing's hardcoded. Otherwise, consult your web server's documentation on how to set an environment variable for the CGI script.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://811932]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2020-01-29 21:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?