As this class will usually be subclassed to implement a reader for a specific style of configuration files, the user-oriented methods will be described first. Methods used to help implement a subclass are described later.
$directive for the configuration
file. You may optionally specify a parsing function or method for the
directive, and a default value.
If $directive is a simple string, it will be used as both the
name of the directive inside of the program and in the configuration file.
You can use an array ref of the form
['program-name', 'name1', 'name2', 'name3' ...]
to use 'program-name' inside of the program, but to recognize any of 'name1', 'name2', 'name3' as the name of directive in the configuration file.
A directive will be set to undef if you don't specify a default value and it is not set in the configuration file.
Any errors or warnings that occur while parsing the default value are normally reported as orginating in the caller's module. You can change the reported location by specifying $whence.
ignore($directive, [$whence])
directives()
value($directive, [$whence])
define_accessors([$package, [@names]])
$config->define_accessors();
...
open(IN, Input_File());
The names of the created subroutines is returned in an array. If you'd like to export the accessor subroutines, you can say:
push @EXPORT, $config->define_accessors();
You can specify the package in which to create the subroutines with the
optional $package argument. You may also specify which
configuration directives to create accessor subroutines for. By default,
subroutines will be created for all the directives.
new() creates and returns a new
ConfigReader::Values object.
Unless the optional $spec argument is present, a new
ConfigReader::Spec object will be created to store the configuration
specification. The directive(), required(),
ignore(), value(), and directive()
methods described above are passed through to the spec object.
By setting $spec, you can use a different class (perhaps a subclass) to store the specification.
You can also set $spec if you want to use one specification
for multiple sets of values. Files like /etc/termcap describe a
configuration for multiple objects (terminals, in this case), but use the
same directives to describe each object.
values()
spec()
assign($directive, $value_string, $whence)
$value_string will be
parsed by the directive's parsing function or method, if any.
$whence should describe the line in the configuration file
which contained the value string.
assign_defaults($whence)
assign_defaults()
method is called to assign the default values for directives which were not
specified in the configuration file. $whence should describe
the name of the configuration file.