Config::YAMLMacros - Include file and string subsitution for YAML configuration files


use Config::YAMLMacros;

my $config = get_config('/some/file');


This module is a wrapper around loading YAML configuration files. It does several things:

expand tabs

Initial tabs on lines are expanded so that YAML doesn't choke on invisible variations in whitespace.

join sections

The YAML file may be split into sections, divided with --- lines. The sections will be merged together to create the final result.

string replacements

You can declare string replacements to use for the rest of the file. For example:

   %FOO%:       BAR

You can declare string replacements where the value of the replacement string is evaluated as a perl expression:

   %FOO%:       $ENV{HOME}

You can turn off the replacements with a NO_REPLACE directive:


include files

You can include additional files as part of your configuration file. They will be merged in.

 INCLUDE: filename.yml

You can specify that the new file override stuff that has already been seen in the current file:

 OVERRIDE_FROM: filename.yml


For the INCLUDE, OVERRIDE_FROM, and NO_REPLACE directives, they can be either lists or a single item:

   - file1.yml
   - file2.yml
   - %FOO%
   - %BAR%
 INCLUDE: justone.yml

These new directives need to be in a yaml block all by themselves (delimited by ---).


This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.