NAME

Config::Universal - Universal object oriented config file reader

SYNOPSIS

use Config::Universal;

my $conf=new Config::Universal();
$conf->ReadConfigFile("my.conf") && die ("ReadConfigFile failed");
my $varval=$conf->GetVarValue("myvarname");

DESCRIPTION

This module is designed to read object structured config files.

METHODS

new(PARAM)

Constructor allows the following parameters:

- none at this time -
ReadConfigFile($filename)

This method reads the config file. If this fails, the method returns a non zero value.

GetVarValue()
GetVarValue($varname)

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($object|$objectname)

Returns the parent object of a given object (by name or by hash-referenz)

ObjectInfo($objname|$object,'FQNAME'|'NAME'|'TYPE','LINE')

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($objname|$object,[TYPERESTRICTION])

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()
GetObject($objecttype)
GetObject($objecttype,$objectname)

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.

SAMPLES

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"
}

AUTHORS

Config::Universal by Hartmut Vogler.

COPYRIGHT

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:

Around line 615:

You forgot a '=back' before '=head1'