Lingua::NATools::Config - Simple configuration file API
use NAT::Config; my $config = Lingua::NATools::Config->new("config.cnf"); my $val = $config->param("key"); $config->param("key", ++$val); $config->write;
The NAT::Config object constructor receives the name of the file to be processed. It returns an NAT::Config object ready to be queried.
my $cnf = Lingua::NATools::Config("/path/to/the/configuration/file")->new;
You can also create a configuration object from scratch:
my $cnf = Lingua::NATools::Config->new;
This is the accessor method for any configuration parameter. Pass it just one argument and you'll get that parameter value. Pass a second argument and you are setting the parameter value.
# get value for key "foo" $val = $cnf->param("foo"); # set value "bar" for key "foo" $cnf->param("foo", "bar");
This is the method used to write down the configuration object to a file. If you have opened a configuration file with
new, then you can just "save it":
If you created a configuration object from scratch, you need to supply a filename:
You can always force a filename.
Alberto Manuel Brandao Simoes, <email@example.com>
Copyright 2002-2012 by Natura Project http://natura.di.uminho.pt
This library is free software; you can redistribute it and/or modify it under the GNU General Public License 2, which you should find on parent directory. Distribution of this module should be done including all NATools package, with respective copyright notice.