my %newhash = map { $_ => { map { delete $_->{COMP} => $_ } @{$hash{$_}} } } keys %hash;