james_ has asked for the wisdom of the Perl Monks concerning the following question:

Venerable monks,

I'm using the Config::Inifiles module to work with a config file. All I need to know is how to change a section name, not a parameter value. Can't find anywhere how to do this.

I've tried:

tie %cfg, 'Config::IniFiles', ( -file => $CFG_FILE); $cfg{$section} = "new section name"; tied( %cfg )->WriteConfig($CFG_FILE) or die "Error";

But to no avail. Any suggestions for this niggly problem would be great.

Replies are listed 'Best First'.
Re: Config::Inifiles section rename
by Anonymous Monk on Nov 21, 2008 at 17:28 UTC
    $cfg{"new section name"} = delete $cfg{$section};
      Due to caveats mentioned in docs, you have to
      $cfg{"new section name"} = {}; %{ $cfg{"new section name"} } = %{ delete $cfg{$section} };