Dominic Mitchell > Config-Setting > Config::Setting

Download:
Config-Setting-0.04.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.04   Source  

NAME ^

Config::Setting - Perl extension for configuration files.

SYNOPSIS ^

  use Config::Setting;
  my $stg = Config::Setting->new;
  $stg->get("section", "key");

DESCRIPTION ^

This module provides an OO interface to a file full of settings. Settings are assumed to be contained in collections (known as "sections"). Each setting has a key and a value. The value of a setting may refer to other settings using a similiar syntax to variables in perl.

Whilst this module can be used directly it is anticipated that it will be subclassed. This way policy regarding the location and layout of the settings can be determined for your project.

METHODS ^

new ( )

The constructor. Takes no arguments.

is_configured ( )

Returns true if more than one configuration file has been found and read.

provider ( )

Returns an object which can be used to collect the contents of files. The default returns a Config::Setting::FileProvider object. You probably want to override this method when you set up your subclass, in order to set the policy for file locations.

parser ( )

Returns a parser object. The default is the Config::Setting::IniParser object. You may want to override this in a subclass if you wish to use an alternative format for your configuration files.

sections ( )

Return a list of which sections are available from this object.

keylist ( SECTION )

Return a list of keys that SECTION contains.

has ( SECTION, KEY )

Returns true if SECTION contains KEY.

expand ( )

Internal use only.

get ( SECTION, KEY )

Return the value of KEY in SECTION. If the value contains any variables of the form ${word}, they will be fully expanded in the return value.

When trying to replace a variable "word", first, "word" will be looked up as a key in the current section. If not found, it will then be looked up sequentially in all the other sections. If still not found, it will be replaced with an empty string.

Expansion is recursive, so an expanded variable can contain other variables.

TODO ^

It would be useful to know where each setting derived from, in order to help debugging.

AUTHOR ^

Dominic Mitchell, <cpan (at) happygiraffe.net>

SEE ALSO ^

Config::Setting::FileProvider, Config::Setting::IniParser, Config::Setting::XMLParser.

syntax highlighting: