The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Config::Path - Path-like config API with multiple file support and arbitrary backends from Config::Any

SYNOPSIS

    use Config::Path;

    my $conf = Config::Path->new(
        files => [ 't/conf/configA.yml', 't/conf/configB.yml' ]
    );

DESCRIPTION

Config::Path is a Yet Another Config module with a few twists that were desired for an internal project:

Multiple files merged into a single, flat hash
Path-based configuration value retrieval
Clean, simple implementation

Multiple-File Merging

If any of your config files contain the same keys, the "right" file wins, using Hash::Merge's RIGHT_PRECEDENT setting. In other words, later file's keys will have precedence over those loaded earlier.

ATTRIBUTES

config_options

HashRef of options passed to Config::Any.

files

The list of files that will be parsed for this configuration.

METHODS

add_file ($file)

Adds the supplied filename to the list of files that will be loaded. Note that adding a file after you've already loaded a config will not change anything. You'll need to call reload if you want to reread the configuration and include the new file.

fetch ($path)

Get a value from the config file. As per the name of this module, fetch takes a path argument in the form of /foo/bar/baz. This is effectively a shorthand way of expressing a series of hash keys. Whatever value is on the end of the keys will be returned. As such, fetch might return undef, scalar, arrayref, hashref or whatever you've stored in the config file.

  my $foo = $config->fetch('/baz/bar/foo');

reload

Rereads the config files specified in files. Well, actually it just blows away the internal state of the config so that the next call will reload the configuration.

AUTHOR

Cory G Watson, <gphat at cpan.org>

ACKNOWLEDGEMENTS

 Jay Shirley
 Mike Eldridge

COPYRIGHT & LICENSE

Copyright 2010 Magazines.com

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 36:

You forgot a '=back' before '=head2'