Config-Simple-Conf

 view release on metacpan or  search on metacpan

lib/Config/Simple/Conf.pm  view on Meta::CPAN

	print "My root is: " . $conf->value('core section', 'path') . "\n";
	print "My section paths are:\n";

	for($conf->value('section name', 'path')){
		print "\t$_\n";
	}

With the resulting output looking something like:

	My root is: /root/to/my/stuff
	My section paths are:
		/root/to/my/stuff/abc
		/root/to/my/stuff/xyz

=head1 SYNOPSIS

use Config::Simple::Conf;

my $conf = Config::Simple::Conf->new('/etc/Something/Example.conf');

print $conf->value('global', 'example_key');

=head1 HANDLING COMMAND LINE ARGUMENTS

Command line arguments are processed automatically when detected within the B<@ARGV> list. The values of these arguments are represented in the special B<argv> section. Command line arguments can be in either a single or double (B<->) hash value such...

A value can be assigned to each argument as well by either placing the value after the B<--key value> or by using an (B<=>) equals sign B<--key=value>. Multiple duplicate keys can be used to generate a list.

Values may also be macros, so a value could be sourced from a configuration file. An example of this might be  B<--color [colors:red]> with the configuration file:

	[colors]
	red   = 255,0,0
	green = 0,255,0
	blue  = 0,0,255

=head2 @ARGV_CLEAN

An @ARGV like list, cleaned of any arguments which have been captured by the parser.

=head1 CONFIG FILE FORMAT

Configuration files are defined as ascii text, with comments lines starting with a pound symbol B<#>, sections, keys, and values. Values may be macro entries referencing other configuration keys.

=head2 SECTION

A section is defined as a single line entry with double square brakets B<[section]>:

	# Define a section
	[section]

=head2 KEYS

Keys are defined within a B<section> as lines with B<keyname = value> type entry

	# Define a value for keyname in section [section]
	[section]
	keyname = value

=head2 USING A MACRO

Macros are defined as square brakets with a B<section:key> entry between them. These are automatically resolved to other configuration sections and keys and that keys value is utilized.

	# Define a value based on a macro
	[section2]
	key = [section:keyname]
=head2 NOTE

Macros may B<NOT> utilize list entries of duplicate macro keys.

=head2 SPECIAL MACROS

Currently there are two special macros which perform useful tasks

=over

=item include

The B<include> key name allows you to include another configuration file with additional configuration information

=item die

The B<die> key will result in the program dying at that spot with an error dumped to STDERR.

=back

=head2 EXAMPLES

	# Include another configuration file
	include = /some/config.cfg

	# Die right here so user changes things
	die

Additionally see the examples/ directory within this libraries distrobution for more configuration file examples

=head1 METHODS

=head2 new()

Config::Simple::Conf->new(FILE, CFHASH)

Generate / Regenerate the configuration hash reference based on on standard Ruckus configuration files and options.

 FILE         -  The configuratino file to process, if
                 undefined @ARGV will be processed for
                 arguments.

 CFHASH       -  An existing configuraiton hash generated
                 by Config::Simple::Conf  in which data should be appended
                 to.

Returns a hash reference with two types of values:

A standard string "abc", and array reference ["a","b","c"].  In cases of unique keys data is stored as a string. In cases were there are multiple duplicate keys data is stored in an array reference.

Keys may make use of other keys values with in the key value.

 Example:
   [example]
   # sets [example:abc] to '123'
   abc = 123

   # sets [efg] to '123'
   efg = [example:abc]

   # sets [example:list] to [1, 2, 3]
   list = 1
   list = 2



( run in 0.645 second using v1.01-cache-2.11-cpan-39bf76dae61 )