XML::Conf - a simple configuration module based on XML
Here follows some examples as the tests are done.
my $c = XML::Conf->new($filename);
$w = $c->FIRSTKEY();
$v = $c->NEXTKEY();
This is the description of the class, currently it only containg only the descriptions of the private and public methods and attributes.
The attribute holding the reference to the actual configuration structure, the top-node so to speak.
This is the attribute for holding the case parameter (see named parameteres to the constructor below).
This is the constructor of the class. It takes a filename as a parameter, and additionally some named parameters:
The argument given to case is used during the construction of the objects by the _trans function, to traverse and utilize on all elements encountered during the traversal through the configuration tree.
This is a signal flag indicating whether a configuration should be read from file (See ReadConfig). If set a newly blessed object will be initialized by ReadConfig.
Apart from the public interface of the new method, the method is also used internally from some of the other methods, the methods usings the constructor are described below.
This method calls Parameters and returns all the sections in the object.
This method reads a file pointed to by the fn attribute and returns a true value upon successful read and initialization (which overides self) by using the new method (constructor).
The WriteConfig method can be used to write the contents of the configuration object to a file. This method takes a filename as argument. The WriteConfig method is used internally by the RewriteConfig method.
The method is used to overwrite a serialized configuration object to a file. It writes to the contents of the fn attribute and used the WriteConfig method (see above).
The TIEHASH is just a wrapper for the new method (the constructor).
The STORE method takes 2 parameters, a key and a value. The value is stored under the key. The method uses the private method _setval.
Deletes/removes the element specified as the argument, uses the private method _delval.
Empties/flushes the configuration object. Works with values underneath the data attribute.
Returns true if the element specified as a the parameter exists, else it returns false. Works with values underneath the data attribute.
Retrieves the first element in the configuration object (tied hash). Works with values underneath the data attribute.
Retrieves the next element in the configuration object (tied hash), the first element if none have been retrieved. Works with values underneath the data attribute.
Returns the complete config object as a hashref in scalar context.
In list context the method returns a hash.
Sets a value in the structure. The method can be given a list of parameters, the longer the list, the deeper the structure. The _setval method works from the data attribute and below.
This method is just an 'alias' of the _setval method. It is currently now used anywhere in the class.
This method does the opposite of _setval, meaning given a list it can remove values at all levels of the configuration tree. The _setval method works from the data attribute and below.
This paragraf contains functions which are not related to the class in public use, these functions are used during construction of the object.
The _trans function takes the case argument given to the constructor and traverses the complete configuration tree and used the sub provided as argument on the elements encountered.
XML::Conf is free software and is released under the Artistic License. See <http://www.perl.com/language/misc/Artistic.html> for details.
This is originally the work of Ariel Brosh, a member of Israel.pm and author of several contributions to CPAN. He has unfortunately passed away and have left behind several Perl modules where this is just one of them.
I volunteered to contribute further to the development of the module, but it is still kept under the name of Ariel Brosh - the original author.
Jonas B. Nielsen <email@example.com>