[Section1]
key1=value1
key2=value2
[Section2]
key1=value1
key2=value2
####
[prod]
ORACLE_HOME=/path/to/oracle/prod
ORACLE_SID=prod_sid
[test]
ORACLE_HOME=/path/to/oracle/test
ORACLE_SID=test_sid
[dev]
ORACLE_HOME=/path/to/oracle/dev
ORACLE_SID=dev_sid
##
##
# Make the module available
use Config::IniFiles;
# now nab the entire config file contents into the %ini hash
my $ConfigFile = "/path/to/inifile/inifile";
tie my %ini, 'Config::IniFiles', (-file => $ConfigFile);
# now grab the relevent section into it's own hash, we're assuming that it's "prod" for this example
my %Config = %{$ini{"prod"}};
# now we have access to our keys in the hash
print "Oracle home is $Config{ORACLE_HOME}";
print "Oracle SID is $Config{ORACLE_SID}";
##
##
- val ($section, $parameter) - Returns the value of the specified parameter in section $section.
- setval ($section, $parameter, $value, [ $value2, ... ]) - Sets the value of parameter $parameter in section $section to $value (or to a set of values).
- newval($setion, $parameter, $value [, $value2, ...]) - Adds a new value to the configuration file.
- delval($section, $parameter) - Deletes the specified value from the configuration file
- Sections - Returns an array containing section names in the configuration file. If
the *nocase* option was turned on when the config object was created,
the section names will be returned in lowercase.