in reply to undef(%hash) not doing what I expect for HoH

%hash is a hash; $hash is a scalar with an unfortunate name.

$hash{foo} is the item in %hash at key "foo". $hash->{foo} is the item in the hashref stored in $hash at key "foo".

undef %hash clears everything from %hash; $hash is untouched. undef %{ $hash } clears everything from the hash referenced by $hash; %hash is untouched. undef $hash replaces the reference to the hash which was in $hash with undef; again, %hash is untouched.

A judicious use strict would have caught this.