There is a little-known feature of perl on Win32 whereby PERL* environment variables can be looked up in the registry (first under HKCU\Software\Perl then under HKLM\Software\Perl) if they are not found in the environment.

(See more details here: http://www.nntp.perl.org/group/perl.par/2009/05/msg4055.html)

I have an Apache2.2/mod_perl2 setup which runs fine as it is, but can easily be broken if an inappropriate PERL5LIB setting is put in the registry. (With a suitably bogus setting in place, pointing at a completely different version of perl installed elsewhere on my machine, I find that the Apache service no longer starts: It fails to load startup.pl, presumably because it is loading C extension modules and tries to load the wrong versions of DLLs from the location specified in the bogus PERL5LIB setting.)

How can I modify my httpd.conf and/or startup.pl files to protect against this? I've tried adding SetEnv and PerlSetEnv directives in httpd.conf, and use lib qw() and BEGIN { $ENV{PERL5LIB}='...' } lines in startup.pl, but Apache still can't load startup.pl and fails to start.

I need to make the Apache/mod_perl setup override any possible PERL5LIB setting in the registry in a self-contained way, so that it can be installed on other machines and not be affected by those other machines having PERL5LIB settings in the registry.


In reply to Overriding the registry's PERL5LIB in mod_perl on Win32 by shay

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.