in reply to confused with a hash which contains reversed keys
my %uniq; for (keys %hash){ if (exists $uniq{scalar reverse $_}){ $uniq{scalar reverse $_} += $hash{$_}; } else { $uniq{$_} = $hash{$_}; } } # untested
Note that the outcome will either contain the key 'AB' or 'BA', but you don't have control over which one occurs (it's not in the spec ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: confused with a hash which contains reversed keys
by FunkyMonk (Bishop) on Dec 03, 2007 at 13:31 UTC | |
by ikegami (Patriarch) on Dec 03, 2007 at 13:44 UTC | |
by Anonymous Monk on Dec 03, 2007 at 14:57 UTC | |
by Anonymous Monk on Dec 03, 2007 at 13:39 UTC |