in reply to A little fun with hashes

If you run this in a loop, you'll eventually get to a point where all the values are non-keys. But this solution assumes you are not interested in the recursion. It also assumes you want to process every key in the hash and not just "0".

my %newhash; foreach my $key ( keys( %hash ) ) { $newhash{$key} = [ map {exists($hash{$_}) ? $hash{$_} : $_;} (valu +es %hash) ]; } %hash = %newhash;