in reply to Fast Way to Combine Two Hashes
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"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Fast Way to Combine Two Hashes
by runrig (Abbot) on Jun 19, 2002 at 00:01 UTC | |
by mirod (Canon) on Jun 19, 2002 at 13:05 UTC | |
by runrig (Abbot) on Jun 19, 2002 at 16:57 UTC |