> %new_hash = map {defined($_) ? $_ : ''} %{$ref2};In recent versions of Perl, you can also use a simpler version that modifies the hash in place:
This is comparable in simplicity to the original code that involved an array instead of a hash.map { $_ = '' unless defined } %$ref2;
In reply to Re: setting values in anonymous hash
by Dominus
in thread setting values in anonymous hash
by agoth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |