Subject: | RenameSection method wanted |
I find myself really wanting a RenameSection method...
=head2 RenameSection ( $sect_name, $new_sect_name )
Renames a section. Does nothing if a section already exists with the new
name.
=cut
sub RenameSection {
my $self = shift;
my $sect = shift;
my $new_sect = shift;
return if not defined $sect;
return if not defined $new_sect;
if ($self->{nocase}) {
$sect = lc($sect);
$sect = lc($sect);
}
return if $sect eq $new_sect;
return if $self->SectionExists($new_sect);
# This is done, the fast way, change if delval changes!!
for ( qw( v sCMT pCMT EOT parms ) ) {
$self->{$_}{$new_sect} = delete $self->{$_}{$sect};
}
@{$self->{sects}} = map { $sect eq $_ ? $new_sect : $_ }
@{$self->{sects}};
$self->RemoveGroupMember($sect);
$self->SetGroupMember($new_sect);
return 1;
} # end RenameSection