pearl0817
New User
Aug 17, 2011, 7:57 AM
Views: 1834

searching for empty keys in multidimensional hash



Hello, This is my first time posting here. I have researched this prior to posting, but couldn't find any solution. I need to clean up hashes stored in our database. Some of them have empty keys, so those have to be deleted. Here's a sample hash:
'Groups' { 'A' => { '' => '45', 'allMembers' => '46,69,45' }, 'B' => { 'BO' => '52', 'allMembers' => '52' }, 'D' => { 'Dive Ops' => '105', 'Diving' => '274', 'allMembers' => '105,274' }, 'F' => { 'FO' => '276', 'allMembers' => '276' }, 'SP' => { 'SP' => '275', 'allMembers' => '275' }, 'rt' => { '' => '91', 'allMembers' => '119,91' } } So taking the first set as an example
'A' => { '' => '45', 'allMembers' => '46,69,45' }, The first value has an empty key,it has to be deleted, and then since there are no more items actually, A has to be deleted altogether. I have a problem with syntax,how do I loop through this hash and single out the empty keys? Any help would be greatly appreciated. Thanks!
