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

#!/fellow/monks.pl

I've been developing a web based app, and I just installed it on my Mandrake box, with mod_perl. Development was done on Redhat 6.2, within cgi-bin, not with mod_perl. I've now moved it to Mandrake, using mod_perl, I found an interesting problem :

The app works fine in CGI, but mod_perl complains that it can't locate my libraries in the require statements. I really do not want to hard code the library paths.

Any words of wisdom on this particular problem?

Thanks!

#!/massyn.pl

Don't -- me without telling me why. If you asked a stupid question, I wouldn't down vote you.

Replies are listed 'Best First'.
Re: CGI works, not with mod_perl??
by liz (Monsignor) on Jul 20, 2003 at 09:57 UTC
    I would verify that you're using the same Perl executable with CGI and mod_perl.

    Compare:

    $ perl -e 'print "INC = @INC\n"'
    with similar code in the mod_perl version and make sure they're the same.

    Liz

      Also, if anything in @INC is relative to the current directory (like .), which it almost certainly will be, make sure that the current directory is the same in both processes.
Re: CGI works, not with mod_perl??
by bobn (Chaplain) on Jul 20, 2003 at 14:22 UTC

    If you're talking about libraries you've wrtitten and installed in other than the standard module locations, you need to a 'use lib' in startup.pl to tell mod_perl where to look. It's still hard coded, but only once.

    From the top of my startup.pl

    BEGIN { use Apache (); # use lib Apache->server_root_relative('lib/perl'); use lib '/usr/local/apache/rushcgi'; # to make 'use Rushglobal' wo +rk }

    Because it runs in startup.pl, all of your apache processes inherit the addition to @INC.

    The commented out line is, I supsect, better for moving things from one server to another. I think it worked for the default location of modules. I'm not sure why I stopped using it. ("What a drag it is, getting o-old.")

    Update: on my RH9 machine @INC looks the same in each environment, including the presence of:

    .

    so I don't get it. However, I may be comparing apples and oranges, as the startup.pl is from an old RH6.0 box that no longer has mod_perl in place, whereas the comparision between CGI and modperl was done on RH 9.

    --Bob Niederman, http://bob-n.com
      Maybe you commented out that line because mod_perl already adds that directory to @INC automatically. There's no need to do it yourself.

        That's a good reason! Thanks for helping out my filing memory.

        --Bob Niederman, http://bob-n.com
Re: CGI works, not with mod_perl??
by thraxil (Prior) on Jul 21, 2003 at 03:01 UTC

    are you using apache2 and Modperl::Registry on the new machine? if so, then you need to keep in mind that it doesn't cwd into the directory of the script before running it like apache 1.x did. that means that anything like:

    use lib qw(.); use Some::Module::Located::In::Same::Directory;

    will fail.

    anders pearson

      I'm using Apache 1.3.27, compiled with gcc, on Mandrake Linux 9.1