Reputation: 643
I need to expand an INI-file in perl. I have a given INI-File that I can read with Config::IniFiles, but I need to add parameters to that INI file too.
For example the file looks like
[section1]
param1=val1
param2=val2
[section2]
param1=val3
param2=val4
and i need to add params to the sections like
[section1]
param1=val1
param2=val2
param3=val5
[section2]
param1=val3
param2=val4
param3=val6
I don't know if there is a Module for that in CPAN. Didn't find one until now that would do the Job. Thank you for any ideas to solve this problem!
Upvotes: 2
Views: 751
Reputation: 13574
Config::IniFiles
allows to add parameters in sections: see newval
#!/usr/bin/perl
use Config::IniFiles;
my $cfg = new Config::IniFiles( -file => "cfg.ini" );
$cfg->newval("section1", "param3", "val5");
# add all new values in corresponding sections ...
$cfg->RewriteConfig;
Read also the section BUGS for RewriteConfig
.
Upvotes: 7