Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Can't find module

by rpike (Scribe)
on Jan 10, 2011 at 16:04 UTC ( #881492=perlquestion: print w/ replies, xml ) Need Help??
rpike has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting an error when trying to run my CGI Perl app in the browser. It's coming back with :
Can't locate Script_Mod.pm in @INC (@INC contains: C:/Inetpub/wwwroot/ +cgi-bin/mods C:/Perl/site/lib C:/Perl/lib .) at c:\inetpub\wwwroot\cg +i-bin\mainScript.pl line 26. BEGIN failed--compilation aborted at c:\inetpub\wwwroot\cgi-bin\mainSc +ript.pl line 26.
Now the main script (one I'm callined) is located in cgi-bin AND the module that it's complaining about is also in the cgi-bin directory. @INC shows "." in the list. So why would the module not get picked up when the main script is running? These same files are located on another server in same locations and work fine. Any suggestions?

Comment on Can't find module
Download Code
Re: Can't find module
by Corion (Pope) on Jan 10, 2011 at 16:06 UTC

    Your current directory is not what you think it is.

    . means "current directory", and not "directory my script lives in.

Re: Can't find module
by rpike (Scribe) on Jan 10, 2011 at 16:10 UTC
    I thought in the process of searching for a module one of the first locations the Perl interpreter looked was the directory the currently running script resided in as well? Thanks for the reply. Whats the easiest way to check the "current directory"? Cwd? Execute statement?

      I thought in the process of searching for a module one of the first locations the Perl interpreter looked was the directory the currently running script resided in as well?

      No, Perl searches the directories in @INC. This often includes the current work directory ("."), but it rarely includes the directory in which the script resides unless it happens to reside in the current work directory.

Re: Can't find module
by ikegami (Pope) on Jan 10, 2011 at 16:28 UTC

    Put the following in your .pl

    use Cwd qw( realpath ); use File::Basename qw( dirname ); use lib dirname(realpath($0));

    Cwd, File::Basename, lib

Re: Can't find module
by rpike (Scribe) on Jan 10, 2011 at 16:39 UTC
    Quick question: on one windows server it worked fine (C:/Inetpub/wwwroot/cgi-bin was current directory when running script). On another Windows server the "current" directory is listed as C:/Inetpub/wwwroot. Where in IIS do I have to change this? On the server that works I type in the browser http://server1/cgi-bin/mainscript.pl and it works, I want to be able to type in http://server2/cgi-bin/mainscript.pl so it works the same way. Also a big thanks for the help as well, I thought both servers were configured the same exact way.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-07-22 11:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (110 votes), past polls