Config::Universal - Universal object oriented config file reader
use Config::Universal; my $conf=new Config::Universal(); $conf->ReadConfigFile("my.conf") && die ("ReadConfigFile failed"); my $varval=$conf->GetVarValue("myvarname");
This module is designed to read object structured config files.
new
Constructor allows the following parameters:
- none at this time -
ReadConfigFile
This method reads the config file. If this fails, the method returns a non zero value.
GetVarValue
With no $varname, the list of global variables (out of object structurs) from configfile is returned. If the $varname is specified, the value of the given name is returned.
FindParentObject
Returns the parent object of a given object (by name or by hash-referenz)
ObjectInfo
Returns the spezifed deltail information for the given object (by name or by hash-referenz) LINE = definition position of object in configfile FQNAME = full qualified name of the object NAME = the short name of object TYPE = object type
FindSubordinate
Returns all subordnate objects with the given objecttype restriction TYPERESTRICTION. If no TYPERESTRICTION is spezified, all subordnate are returned. If no subordnates are found, an empty array is returend.
GetObject
With no paramaters, the method returns the list of available object types in current config.
If the $objecttype is specified, the list of objectnames in the given $objecttype is returned.
If $objecttype and $objectname is specified, the value ob the described variable is returned.
General you should use only lowercase characters for variable, objecttypes and objectnames. Of curse there are upper case characters are useable too, but the only use of lower case creates a better readable config. The simples kind of configuration are simple variables.
# # remarks starting with # # server="myserver" ipadress="192.168.2.2","192.168.1.2"
The next level of configuration is to create objects. A object has always one type and sometimes a name. If no name is given, Config::Universal create a uniq name at the given objecttype.
server "myserver" { ipadress="192.168.2.2","192.168.1.2" } server{ ipadress="164.168.2.2","164.168.1.2" }
Config::Universal makes it posible, to use object inheritance. At the following sample, every server object has the variable os="linux".
{ os="linux" server "servera" { ipadress="192.168.2.2","192.168.1.2" } server "serverb" { ipadress="164.168.2.2","164.168.1.2" } }
It is posible to include an outher configfile, but a include directrive ist only outsite object structures alowed.
server "myserver" { ipadress="192.168.2.2","192.168.1.2" } @INCLUDE "/etc/one.other.conf"
If at one object no name is spezifed, an automatic name is generated. If this mode is used, the name of the object can be diffrent between each run ob ReadConfigFile()!
server "myserver" { ipadress="192.168.2.2","192.168.1.2" disk{ name="/dev/hda" } disk{ name="/dev/hdb" } }
References objects would be automaticly checked and dereferenced. The corespondenting variable would have a array reference with the hash references to the adressed objects. The object names must be always spezified full qualified!
server "myserver" { eventhandler="ev1","myserver.ev2" eventhandler "ev2"{ name="/etc/ev2" } } eventhandler "ev1"{ name="/etc/ev1" }
Config::Universal by Hartmut Vogler.
The Config::Universal is Copyright (c) 2005 Hartmut Vogler. Germany. All rights reserved.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Config::Universal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Universal
CPAN shell
perl -MCPAN -e shell install Config::Universal
For more information on module installation, please visit the detailed CPAN module installation guide.