Odd behavior of mod_perl's PerlSetEnv with PERL5LIB

T

Tony Skelding

I am using a PerlSetEnv directive in order to have PERL5LIB set to a
directory list at request time. But the directories are being added
to @INC in reverse order.

For example, in my httpd.conf I have...

PerlSetEnv PERL5LIB foo:bar:xyzzy

In my handler I have...

print "$_\n" for @INC;

The output I get is...

xyzzy
bar
foo
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0

However, if I simply set an environment variable in my shell, e.g.

$ export PERL5LIB=foo:bar:xyzzy
$ perl -e 'print "$_\n" for @INC'

I get...

foo
bar
xyzzy
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
..
 
P

pkent

I am using a PerlSetEnv directive in order to have PERL5LIB set to a
directory list at request time. But the directories are being added
to @INC in reverse order.

We've noticed this at work too. I believe it's a known issue and our
workaround is to do:

Set Env PERL5LIB lookherefirst:lookheresecond:lookherefirst

to cover both the CGI and mod_perl possibilities. Personally I have no
idea why it does it, and I certainly don't think it's desirable, but
you're not the only one to notice it

P
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top