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

A simple question pertaining to config for applications.

Imagine you have an ISP that gives you a classic ftp area like one of these two:

/home/yourhost/www /home/yourhost/cgi-bin
... and you add:
/home/yourhost/lib/perl /home/youhost/scripts

I've added scripts, because I also have telnet access and I put all my modules in lib perl.

Right, here's the question:

What method do you use to minimise the ammount of updates required to each scripts and cgi scripts if this directory was to change.

More interestingly, there might be a test server or a development machine with different file system structures. So everytime there was a test or site update, a few things will change.

So, minimum change is what I'm up for.

Your thoughts wise ones.

--
Steve Marvell

Replies are listed 'Best First'.
Re: favourite config method
by fglock (Vicar) on Aug 08, 2002 at 13:12 UTC

    I use ln -s in the development machine directories, trying to replicate the production setup, so I don't have to bother reconfiguring the scripts.

Re: favourite config method
by waswas-fng (Curate) on Aug 08, 2002 at 14:38 UTC
    I agree linking files to a static tree makes life easy. Just a few more additions though. Linking tends to get messy if the trees are very fluid (you tend to restructure the source or destination trees often). Try to stabilize the drop part of the links.

    Linking also allows for transparent version control for scripts. Take this example:
    /data/home/user/scripts/ make_dbm_history has the link pointing back to /data/home/user/lib/perl/make_dbm_history-2002-02-10-01. If you update the make_dbm_history script in lib/perl you just relink the user/scripts link to the new revision. That way the revision information is scoped out of the everyday use of the script – you never have to change any scripts of settings that point to /data/home/user/scripts/make_dbm_history.

    One more thing that has worked for me in the past is to also have a central config file that stores a lot of static info (user home dir, logging dir, temp working basedir etc) and load those with the storable mod. This way you just need to change one file if the tree changes drastically.

    -Waswas

      One more thing that has worked for me in the past is to also have a central config file ...

      This I like, but has problems getting info from it into a use lib line. The config file can contain a lot, but how do you get that and libs into your perl script. This is my question. I'm doing:

      use lib '/some/static/path'; use MyModule::Config;

      This means I have to change one line per script.

      Is this optimal?

      --
      Steve Marvell

        I use:
        use Storable; $global_config = retrieve('/path/to/my/config.sto');
        in my scripts, that way I can access things like $global_config{'logdir'} globally. I have another script which can add/change/delete hash entries and then nstore \%global_config, '/path/to/my/config.sto'; them.
        It seems to load up very quickly and has worked very well for me in the past.

        -Waswas