NAME

Config::Onion - Layered configuration, because configs are like ogres

VERSION

version 1.002

SYNOPSIS

my $cfg = Config::Onion->new;
my $cfg = Config::Onion->set_default(db => {name => 'foo', password => 'bar'});
my $cfg = Config::Onion->load('/etc/myapp', './myapp');
my $cfg = Config::Onion->load_glob('./plugins/*');

$cfg->set_default(font => 'Comic Sans');
$cfg->load('config');
$cfg->load_glob('conf.d/myapp*');
$cfg->set_override(font => 'Arial');

my $dbname = $cfg->get->{db}{name};
my $plain_hashref_conf = $cfg->get;
my $dbpassword = $plain_hashref_conf->{db}{password};

DESCRIPTION

All too often, configuration is not a universal or one-time thing, yet most configuration-handling treats it as such. Perhaps you can only load one config file. If you can load more than one, you often have to load all of them at the same time or each is stored completely independently, preventing one from being able to override another. Config::Onion changes that.

Config::Onion stores all configuration settings in four layers: Defaults, Main, Local, and Override. Each layer can be added to as many times as you like. Within each layer, settings which are given multiple times will take the last specified value, while those which are not repeated will remain untouched.

$cfg->set_default(name => 'Arthur Dent', location => 'Earth');
$cfg->set_default(location => 'Magrathea');
# In the Default layer, 'name' is still 'Arthur Dent', but 'location' has
# been changed to 'Magrathea'.

Regardless of the order in which they are set, values in Main will always override values in the Default layer, the Local layer always overrides both Default and Main, and the Override layer overrides all the others.

The design intent for each layer is:

METHODS

new

load(@file_stems)

load_glob(@globs)

set_default([\%settings,...,] %settings)

set_override([\%settings,...,] %settings)

PROPERTIES

cfg

get

default

main

local

override

CONFIGURATION

$Config::Onion::prefix_key

Prefix Structures

BUGS AND LIMITATIONS

AUTHOR

COPYRIGHT AND LICENSE