This is very simple using Config::Tiny
but there is no way to rename a value directly - you have to copy the value to an item with the new name and then delete the old one.
This short Perl program demonstrates. It changes parameter1
to newparam1
and parameter2
to newparam2
. The new config is written to a different file to facilitate testing, but you will probably want to override the original file.
use strict;
use warnings;
use Config::Tiny;
my $cfg = Config::Tiny->read('file.cfg');
#print $cfg->{'section 1'}{parameter1};
my $section1 = $cfg->{'section 1'};
$section1->{newparam1} = $section1->{parameter1};
delete $section1->{parameter1};
$section1->{newparam2} = $section1->{parameter2};
delete $section1->{parameter2};
$cfg->write('newfile.cfg');
output
[section 1]
newparam1=value1
newparam2=value2