I have a C application that includes a few perl scripts and modules. Upon ./configure && make install, automake updates a variable in the perl scripts "use lib" line to point to the installed location. Works great:

use lib qw( @@perlmoduledir@@ );

Now, the application has been ported to Windows. The problem is how to set @INC. Our Windows installer can't do the search and replace in the scripts to modify the "use lib" line in each script.

Setting PERL5LIB would not work because I can't depend on the environment (scripts run from a shell or from a web server). And I have no idea how to set PERL5LIB portably under different versions of Windows. Not to mention rebooting to install something is a hideous idea.

ActiveState, I believe, will read the registry key \\HKLM\Software\Perl\sitelib to set @INC but that would mean that we couldn't have more than one version of our application installed at the same time.

So it would seem the best method would be to set a version specific registry key at install time and have our scripts read the registry to set @INC before calling require to load modules.

Is that the best solution? And can I assume that under Windows there will be a module for accessing the registry available? Something like Win32API::Registry??

Can someone provide guidance?


In reply to Setting @INC on Windows by Anonymous Monk

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.