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

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?

Replies are listed 'Best First'.
Re: Setting @INC on Windows
by tommyw (Hermit) on Jul 30, 2003 at 15:59 UTC

    This seems to easy to be feasible, but can't you use the installed perl to make the change for you?

    perl -pi -e 's|@@perlmoduledir@@|path_you_want|g' script1 script2

    Maybe?

    --
    Tommy
    Too stupid to live.
    Too stubborn to die.

      Make sure you use perl -pi.bak or similar - omitting the '.bak' rename extension on Windows causes problems...
Re: Setting @INC on Windows
by demerphq (Chancellor) on Jul 30, 2003 at 18:57 UTC

    You want Win32::TieRegistry by tye. (Which is included in any AS build, or can be installed from the latest copy of libwin32.)


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...