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;
In reply to Re: A little fun with hashes
by ehdonhon
in thread A little fun with hashes
by abitkin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |