Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Combining Multiple Scripts and their Configuration Files into a Hierarchical Configuration

by hackdaddy (Hermit)
on Jul 10, 2002 at 17:25 UTC ( [id://180814]=perlquestion: print w/replies, xml ) Need Help??

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

I have a several scripts that use AppConfig module for their configuration files. However, I would like to implement a master script which runs the scripts as subordinates.

Furthermore, I would like the master script's configuration file to be able to override configuration settings in the configuration files of the subordinate script. I am not sure that AppConfig is the appropriate module for this design.

How do I design a configuration system where there is a hierarchical configuration with the parent overriding the child's configuration? An example that comes to mind is the IIS web server metabase. What other designs for hierarchical configuration are possible? Thanks!

  • Comment on Combining Multiple Scripts and their Configuration Files into a Hierarchical Configuration

Replies are listed 'Best First'.
Re: Combining Multiple Scripts and their Configuration Files into a Hierarchical Configuration
by fuzzyping (Chaplain) on Jul 10, 2002 at 18:27 UTC
    I would think it would simply be a matter of reading in your master config and assigning the values to variables. Then, when you need to read in the localized configs, simply check to see if they're already defined... if so, skip them.

    I haven't used AppConfig, but if you're used to Windows-style config files, I would suggest you look into Config::IniFiles.

    Good Luck!

    -fp
Re: Combining Multiple Scripts and their Configuration Files into a Hierarchical Configuration
by Aristotle (Chancellor) on Jul 10, 2002 at 22:14 UTC
    Quoting the AppConfig POD:

    Multiple files may be passed to file() and should indicate the file name or be a reference to an open file handle or glob.

    $config->file($filename, $filehandle, \*STDIN, ...);

    [...]

    room = /home/kitchen room /home/bedroom

    Each subsequent re-definition of the variable value overwrites the previous value.

    print $config->room(); # prints "/home/bedroom"
    I suggest you use a --mastercfg or similar option in your subordinate scripts, which they will then read after their default configuration file so that AppConfig will override the variables first seen in the default configuration file with the values later seen in the master configuration file.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://180814]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-24 22:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found