$x{$k} &&= $v;
I expected the previous code to modify the hash only if the key is already there (and with a true value), or leave the hash untouched otherwise.
The problem is that your code is testing the value of the hash. In order to test the hash key you have to use the exists operator. From your description you want something like this:
$x{$k} = $v if exists $x{$k} && $k;
In reply to Re: &&= vivify keys?
by jwkrahn
in thread &&= vivify keys?
by oha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |