I don't know if it is faster but at least it is shorter:
@set2{keys %set1}=undef;You can test it with:
#!/usr/bin/perl -w use strict; my %set1=( k1 => 1, k2 => 2, k4 => 2); my %set2=( k1 => 1, k3 => 2, k4 => 2); @set2{keys %set1}=undef; while( my( $k, $v)= each %set2) { $v='undef' unless( defined $v); print "$k => $v\n"; }
In reply to Re: Fast Way to Combine Two Hashes
by mirod
in thread Fast Way to Combine Two Hashes
by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |