Config-Merge

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

       $hosts_ref    = C('db.hosts.sesssion');
       @cloned_hosts = My::Config::clone('db.hosts.session');
       $config       = My::Config::object;
       -------------------------------------------------------

    ADVANCED USAGE

       OO style
       -------------------------------------------------------
       my $config    = Config::Merge->new(
           path      => '/path/to/config',
           skip      => sub {} | regex | {} ,
           is_local  => sub {} | regex | {} ,
           load_as   => sub {} | regex ,
           sort      => sub {} ,
           debug     => 1 | 0
       );
       -------------------------------------------------------

       Functional style
       -------------------------------------------------------
       use Config::Merge(
           'My::Config' => '/path/to/config',
           {
               skip      => sub {} | regex | {} ,
               is_local  => sub {} | regex | {} ,
               load_as   => sub {} | regex ,
               sort      => sub {} ,
               debug     => 1 | 0
           }
       );

       # Also, you can subclass these:

         package My::Config;
         sub skip {
             ...
         }

       -------------------------------------------------------

DESCRIPTION
    Config::Merge is a configuration module which has six goals:

    *   Flexible storage

        Store all configuration in your format(s) of choice (YAML, JSON,
        INI, XML, Perl, Config::General / Apache-style config) broken down
        into individual files in a configuration directory tree, for easy
        maintenance. See "CONFIG TREE LAYOUT"

    *   Flexible access

        Provide a simple, easy to read, concise way of accessing the
        configuration values (similar to Template). See "ACCESSING CONFIG
        DATA"

    *   Minimal maintenance

        Specify the location of the configuration files only once per
        application, so that it requires minimal effort to relocate. See
        "USING Config::Merge"

    *   Easy to alter development environment

        Provide a way for overriding configuration values on a development
        machine, so that differences between the dev environment and the
        live environment do not get copied over accidentally. See
        "OVERRIDING CONFIG LOCALLY"

    *   Minimise memory use

        Load all config at startup so that (eg in the mod_perl environment)
        the data is shared between all child processes. See "MINIMISING
        MEMORY USE"

    *   Flexible implementation

        You may want to use a different schema for your configuration files,
        so you can pass in (or subclass) methods for determining how your
        files are merged. See "ADVANCED USAGE".

USING "Config::Merge"
    There are two ways to use "Config::Merge":

    OO STYLE
           use Config::Merge();
           my $config    = Config::Merge->new('/path/to/config');

           @hosts        = $config->('db.hosts.session');
           $hosts_ref    = $config->('db.hosts.session');
           @cloned_hosts = $config->clone('db.hosts.session');

        Also, see "ADVANCED USAGE".

    YOUR OWN CONFIG CLASS (functional style)
        The following code:

           # On startup
           use Config::Merge('My::Config' => '/path/to/config');

        *   auto-generates the class "My::Config"

        *   loads the configuration data in '/path/to/config'

        *   creates the subs "My::Config::C", "My::Config::clone" and
            "My::Config::object".

        Then when you want your application to have access to your
        configuration data, you add this (eg in your class "My::Module"):

           package My::Module;
           use My::Config;       # Note, no ()

        This exports the sub "C" into your current package, which allows you
        to access your configuation data as follows:

           @hosts        = C('db.hosts.sesssion');
           $hosts_ref    = C('db.hosts.sesssion');
           @cloned_hosts = My::Config::clone('db.hosts.session');
           $config       = My::Config::object;



( run in 0.805 second using v1.01-cache-2.11-cpan-71847e10f99 )