Actually not. If you look at the original question, all values for the keys of %set2 should be set to undef. undef @set2{keys %set1}; leaves the original value in the hash. @set2{keys %set1}=undef; performs exactly as the original foreach $key (keys %set1) { $set2{$key} = undef; }.
In fact @set2{keys %set1}= (undef) x scalar keys %set1; is more correct (thanks to Zaxo for providing it), but might be slower.
In reply to Re: Re: Re: Fast Way to Combine Two Hashes
by mirod
in thread Fast Way to Combine Two Hashes
by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |