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

I was trying to port a CGI script I had written to use mod_perl. I installed mod_perl and wrote a sample script to verify that mod_perl was in fact installed and operational. The next thing I tried was to copy everything from the /cgi-bin directory on my server (my script, module, config file, and template) to the /perl directory, then run it from my browser. This resulted in the following in my server error log:
[Tue May 22 14:21:51 2001] [error] Can't locate DEVNET.pm in @INC (@IN +C contains: D:/Perl/lib D:/Perl/site/lib . d:/apache/apache/ d:/apach +e/apache/lib/perl) at d:/www/perl/query.cgi line 16.
If I copy the code from my module into my script and remove the use line, I get a similar error when it tries to read the config file or the template. What am I doing wrong? Why does this work perfectly if I am not using mod_perl?

Thank you!

Replies are listed 'Best First'.
Re: mod_perl losing/confusing file paths?
by Odud (Pilgrim) on May 22, 2001 at 23:52 UTC
    Also try hitting refresh a lot of times and see if the results vary - if they do then it is because you are using different processes and implies a mod_perl/apache config problem. If it doesn't then it implies something in your script. Running the script from the command line might provide insights as well. I can heartily recommend Stas Beckman'spages for some good documentation/tutorials on mod_perl.
Re: mod_perl losing/confusing file paths?
by Odud (Pilgrim) on May 22, 2001 at 23:48 UTC
    Are you trying to use the "automatic reload" of changed modules - Apache::Reload or Apache::StatINC or something similiar. If so I think you need to make sure that the directory is in @INC (I can see /apache/lib/perl but I don't know if that is what you are using). Perhaps you could reply and let us know what you have added to httpd.conf to get mod_perl working.
      My httpd.conf file (the applicable parts anyhow) looks like this:
      LoadModule perl_module modules/mod_perl.so PerlModule Apache::Registry PerlModule Apache::DBI Alias /perl/ d:/www/perl/ <Location /perl> SetHandler perl-script PerlHandler Apache::Registry Options ExecCGI PerlSendHeader on allow from all </Location>
      I haven't done anything special with Apache::Reload, etc. I just copied my CGIs over and tried to run them.

      Hope this helps. Thank you!

        This looks o.k. but is your perl directory in @INC? if not you can add it in the startup script (startup.pl)
        use lib qw(/home/httpd/perl); # for example
        I don't really know why this works but it did for me. Also you can start up Apache with a single server process -XI think which would be worth trying to see if you still get the problem.
Re: mod_perl losing/confusing file paths?
by arturo (Vicar) on May 23, 2001 at 01:13 UTC

    Another place to look: try perl -V on your system's perl binary and see what @INC is; if it's different from the one reported by the error message, then your problem is probably that you have a different perl interpreter embedded in Apache than your system perl.

    You might also try adding use lib 'path/to/devnet/pm/file' to your startup file.

    HTH

    perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'