in reply to Ignore Case when comparing Hash Keys
First transform one of the hashes to use all lowercase keys. Then check existence of lc $other_key.
Here's a Perl 6 solution:
my %lc1 = %hash1.keys>>.lc Z %hash1.values; for %hash2.keys -> $k { say "$k ", %lc1.exists($k) ?? 'Matched' !! 'Did not match'; }
Transforming the code to Perl 5 shouldn't be too hard.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Ignore Case when comparing Hash Keys
by avidcoder (Novice) on Nov 15, 2010 at 18:56 UTC | |
by roboticus (Chancellor) on Nov 15, 2010 at 19:06 UTC | |
by avidcoder (Novice) on Nov 15, 2010 at 19:25 UTC | |
by roboticus (Chancellor) on Nov 15, 2010 at 20:09 UTC | |
by moritz (Cardinal) on Nov 15, 2010 at 20:03 UTC |
In Section
Seekers of Perl Wisdom