Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Changing Perl compile-time configuration settings

by Bloodrage (Monk)
on Feb 20, 2008 at 01:36 UTC ( #668923=perlquestion: print w/replies, xml ) Need Help??

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

I've copied Strawberry Perl (which implies Win32) onto a removable flash drive. I have a batch command that sets the PATH and other $ENV settings correctly making perl, cpan, and nmake accessible. I have also written a Perl script that modifies cpan's so that cpan can download, build and install modules (almost) correctly into the Perl install on the flash drive. (Why? I have broadband at work, and not at home, it was getting irritating to bring home a bunch of module tarballs only to find that they required missing dependencies). It almost works except that Perl has some compile time settings (mostly paths) that need to be changed. They seem to be in X:\strawberry\perl\lib\, but also appear in X:\strawberry\perl\lib\ and X:\strawberry\perl\lib\CORE\config.h and probably a bunch of others too. (Note: with a removable drive the X: changes from system to system, hence the need to change these configurations)

Can I just edit, or will I also need to do something with perl.exe? Is there a Perl module that already does these things? (I couldn't find one)

So far the Perl-onna-stick thing is working really well for writing and running scripts (i.e. doing things with Perl), but is having small issues with installing modules etc (i.e. doing things to Perl) because it thinks everything should be stored off the C:\strawberry\perl path prefix.

The trick after this will be trying to incorporate GTK2-perl.

Update: I've given using a script to edit Perl's and a whirl... it works!

When I'm done I'll try and write a coherent article on "RFC: Changing Perl Config settings" and and another on "Strawberry-Perl-onna-Stick".

Replies are listed 'Best First'.
Re: Changing Perl compile-time configuration settings
by syphilis (Archbishop) on Feb 20, 2008 at 04:35 UTC
    Changing the paths specified in and should be all you need to do, and afaik that should work.

    I'd be loathe to mess with Config.h. I don't think that's necessary, anyway.

Re: Changing Perl compile-time configuration settings
by CountZero (Bishop) on Feb 20, 2008 at 06:57 UTC
    ActiveState Perl provides a batch script "reloc_perl.bat" that in its turn uses the "ActiveState::RelocateTree" module to change all necessary paths when your Perl moves to a new location. It is much more complicated than just adjusting a few config-files (it even looks inside binary files!) so unless ActiveState Perl is totally different from Strawberry Perl I guess that there is more to it than just the config-locations to be changed.

    Perhaps you can look at the AS files and be inspired by them?


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Actually, it's not "much more complicated" - changing the configuration files is all that I found to be needed. I briefly looked at the source of reloc_perl.bat and ActiveState::RelocateTree, and didn't find where the list of files gets passed around.

      I have moved both, ActiveState and Strawberry Perl around, and the only things that needed change were and CPAN/

      Update: D'oh - of course, syphilis is right, is another place that needs changing.

        the only things that needed change were and CPAN/

        If you don't make any changes to there will still be a number of config values pointing to the original location. I would think that would break something sooner or later.

        Though, I guess, perhaps the amendments made in CPAN/ override those settings ? (I have no experience with

        ...ok... scanning ActiveState::RelocateTree<br< />

        It looks like it checks every file in the ActiveState installation (without reading too much about File::Find), checks with a regex in the check subroutine to see if they contain the $opt{from} string (which is the current $Config{prefix}), then pass the files to the edit subroutine which search and replaces the from location with the to location (and pads binary files).

        It's comprehensive brute force, and probably OTT.

        I should really do a grep for all files with C:\strawberry\ and see how long the list is...

Re: Changing Perl compile-time configuration settings
by adamk (Chaplain) on Feb 20, 2008 at 13:03 UTC
    Obviously it's sub-optimal to move the distribution every single time. It would be better if it just auto-detected the correct locations.

    I've done a little experimentation with this...

    Take a look at to see my experimental replacements for and CPAN/ (haven't done yet).

    You might want to try copying those files into your install.

    Of course, you'd have to also create a similarly-modified form of which you would then of course mail to me :)

      Hmm, your solution looks really nifty. I might switch to something like that when I've finished this attempt.

      My solution is to run a script which targets specific config settings for replacement. For CPAN's it does a little bit more than s/?:\\strawberry/$new_prefix/ (mostly pointing to some other include files on the flash drive). Perl's on the other hand just needs a search/replace done on it. looks like it needs a combination (and to be honest it hasn't been done properly! there's a lot of references to usr/lib and similar unixisms).

      I have a U3 drive because I like UltraEdit32 and the U3 version is pretty much everything you need for non-compiled languages. (I use it for Perl, Javascript, and XHTML).

      Here's the script so far, I'll get to work on it more tomorrow. It's a bit niave in some places (uh, like how I haven't used rename) and needs some of the debugging code stripped out.

      Updated: Now does Perl's Updated again: Now does
      Looking at it's going to be a heavyweight combination of the two approaches I've used so far, and at this time of night the code's likely to read like the script from an episode of Deadwood.

        After a good night sleep isn't quite so scary. A s!.:/strawberry!$strawberryDir!g does most of the work, but there are these other options that probably shouldn't be left as they are because they still contain unix paths. This might account for the occasional X:\strawberry\perl\lib/foo/baa mangled paths seen in logs and error reports.

        Exerpts from
        glibpth='/usr/shlib /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/ +386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/u +cblib /usr/shlib ' ... locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt +/gnu/include /usr/GNU/include /opt/GNU/include' loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /us +r/GNU/lib /opt/GNU/lib' ... strings='/usr/include/string.h' ... sysman='/usr/man/man1' ... timeincl='/usr/include/sys/time.h ' ... xlibpth='/usr/lib/386 /lib/386'

        Update: Read Config manual page. Some of these are redundant. Others are easily redirected, and should really have been sorted during compile time, i.e. the Configure script didn't really set them correctly prior to compiling. It seems safe to redirect them to appropriate include and lib directories.

Re: Changing Perl compile-time configuration settings
by Bloodrage (Monk) on Feb 20, 2008 at 07:14 UTC
    PS. Using Strawberry Perl because it comes with nmake, the mingw compiler, and assorted library and include files specifically for compiling modules. (...but Glib and GTK2 still being awkward)
Re: Changing Perl compile-time configuration settings
by Aim9b (Monk) on Feb 20, 2008 at 13:12 UTC
    I'm a relative newbie, but... Since you're on Windows, what's the possibility of taking the opposite approach, & making the thumb drive ALWAYS be the same letter. Then just assigning C:\strawberry\etc... to the X: or Q: or whatever you've mapped it to?

      My assumption is that group policies etc. have been properly secured (except for the use of flash drives, doh!) and you can't do squat machine wise. You get the drive you're given.

      I also want to be able to take this thing to meetings/interviews jam it in the Windows presentation machine and my scripts to work.

Re: Changing Perl compile-time configuration settings
by Bloodrage (Monk) on Feb 23, 2008 at 22:03 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://668923]
Front-paged by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2022-05-20 23:34 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (76 votes). Check out past polls.