You don't indicate why you need to do this so the following may be rather more than you need. However, this finds all case insensitive matching keys and reports them:

use strict; use warnings; my %hash1 = (TEXT => 25, Text => 25, Wibble => 20); my %hash2 = (text => 25, TexT => 25, wibble => 20); my %h1Keys; my %h2Keys; push @{$h1Keys{lc $_}}, $_ for keys %hash1; push @{$h2Keys{lc $_}}, $_ for keys %hash2; my @common = grep {exists $h2Keys{$_}} keys %h1Keys; print "Hash 1 keys \[@{$h1Keys{$_}}\] match \[@{$h2Keys{$_}}\] in hash + 2\n" for @common;

Prints:

Hash 1 keys [Wibble] match [wibble] in hash 2 Hash 1 keys [TEXT Text] match [text TexT] in hash 2

BTW, always use strictures (use strict; use warnings; - see The strictures, according to Seuss).


Perl reduces RSI - it saves typing

In reply to Re: Comparing two hashes for duplicate keys with no case sensitivity by GrandFather
in thread Comparing two hashes for duplicate keys with no case sensitivity by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.