Perl: Compare 2 hash table values

@pataka : I am not printing twice but doing comparison for both alpha-numeric strings . So i have printed one for stings and another for numbers . We can do the same even in this way as shown below:

    #Same Key and Value
foreach my $val1 (keys %hash1)
 {
      foreach my $val2 (keys %hash2)   {

             if($val1 eq $val2)        {
                  if($hash1{$val1} eq $hash2{$val2}) {
                    print "Key:$val1\t" ;
                    print "Value:$hash1{$val1}\n";

                      }   
                  }  
                }
        }

Leave a Comment