print "\nDelete children of $test :\n"; foreach $key (keys %index) { ... delete $index{$key}; } #### foreach $key (%index) { delete $index{$key}; }