Config::Tree::Env - Read configuration tree from environment variables


Config-Tree documentation  | view source Contained in the Config-Tree distribution.

Index


NAME

Top

Config::Tree::Env - Read configuration tree from environment variables

SYNOPSIS

Top

 # in Bash-like shell:

 % CONFIG_FOO__BAR=3 perl script.pl
 % CONFIG_FOO='{bar: 3}' perl script.pl; # same thing

 # in script.pl:

 use Config::Tree::Env;

 my $conf = Config::Tree::Env->new(
     # schema => ...,
     # include_path_re => qr/.../,
     # exclude_path_re => qr/.../,
     # env_path_separator => '__',
     # env_prefix => 'CONFIG_',
     # env_lowercase => 1,
     # env_as_yaml => 1,
     ro    => 0,
 );
 my $val = $conf->get('/foo/bar'); # 3
 $conf->cd('/foo');
 $conf->set('bar', 10); # same as set('/foo/bar', 10);




DESCRIPTION

Top

This module, CT::Env, construct config tree from environment variables. By default, only config variables beginning with CONFIG_ will be parsed (can be changed with env_prefix property). By default, __ in environment variable's names will be regarded as path separator (can be changed with env_path_separator property). Also, by default, environment variable's name will be converted to lowercase (can be prevented by setting env_lowercase property to 0). So, environment variable CONFIG_FOO__BAR will become /foo/bar while CONFIG_FOO_BAR will become /foo_bar and FOO_BAR will be ignored.

ATTRIBUTES

Top

METHODS

Top

new(%args)

Construct a new Config::Tree::Env object. Arguments.

set($path, $val)

Does nothing.

save()

Does nothing.

SEE ALSO

Top

Data::Schema, Config::Tree::Base

AUTHOR

Top

Steven Haryanto, <stevenharyanto at gmail.com>

COPYRIGHT & LICENSE

Top


Config-Tree documentation  | view source Contained in the Config-Tree distribution.