my %hash1 = ("TEXT", 25,"test",26,"tset",27); my %hash2 = ("text", 25,"TeSt",24,"xyz",23); foreach (do { my %matcher; @matcher{map lc,keys %hash1}=(); grep exists $matcher{lc $_},keys %hash2; }) { print "$_ matches\n"; }