in reply to Re: apache2 passing PERL5LIB environment to cgi
in thread apache2 passing PERL5LIB environment to cgi

I have a little test script that use the module

#!/usr/bin/perl -w

use lib "$ENV{HOME}/lib/perl5";
use Unicode::String qw(utf8 latin1 utf16be);

If I have "export PERL5LIB=~/lib/perl5" it works, and with commented out it does not work.

  • Comment on Re^2: apache2 passing PERL5LIB environment to cgi

Replies are listed 'Best First'.
Re^3: apache2 passing PERL5LIB environment to cgi
by ikegami (Patriarch) on Jun 14, 2010 at 20:05 UTC
    That makes no sense. They should be equivalent. Both of the following should work, or both should fail.
    PERL5LIB= perl -e'use lib "$ENV{HOME}/lib/perl5"; use Unicode::String +qw(utf8 latin1 utf16be);' PERL5LIB=$HOME/lib/perl5 perl -e'use Unicode::String qw(utf8 latin1 ut +f16be);'

    Could you confirm or refute?

Re^3: apache2 passing PERL5LIB environment to cgi
by AndyZaft (Hermit) on Jun 14, 2010 at 20:11 UTC
    Hmm, never used perl with apache without mod_perl before. Does it start a new perl instance on every cgi call? So at least you get response from the script right? I mean as HTML in a browser. When you print @INC after your use lib line, do you see your $HOME/lib/perl5 in there? Was just wondering if ENV{$HOME} actually would have the right path or would show up something like /home/nobody/lib/perl5 or /lib/perl5?
      Does it start a new perl instance on every cgi call?

      The definition of CGI is start a new instance on every call, read input (form data or whatever) from STDIN, read headers from %ENV, write output on STDOUT.

        Erm... I guess I should've clarified, afaik when you are using mod_perl that gives you a built in interpreter in the apache server as a module so your apache instance doesn't have to call the external perl executable every time it encounters a call to a CGI written in perl.