in reply to Re: Hash table question
in thread Hash table question
You want:
But if you really want all three at once:my @common = grep exists $hash2{$_}, keys %hash1; my @unique1 = grep !exists $hash2{$_}, keys %hash1; my @unique2 = grep !exists $hash1{$_}, keys %hash2;
And then each element of %t will be "1" for 1 only, "2" for 2 only, or "12" for both.my %t; $t{$_} .= "1" for keys %hash1; $t{$_} .= "2" for keys %hash2;
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|