.------[ Egleton, Gary wrote (2002/10/16 at 14:54:57) ]------ | | Hi, | | can any one point me at how to compare two hases. | | ie | | hash1 | 1 abc | 2 def | 3 ghi | | hash2 | 1 abc | 2 defzzz | 3 ghi | | I want to take the values for matching keys and see if they are the same if | not write out the value | | so in the above the values in 1 and 1 are ok, the values in 3 and 3 are ok | but in key 2 they do not match | `-------------------------------------------------
This should do it: foreach my $key ( keys(%hash1) ) { if( $hash1{$key} ne $hash2{$key} ) { print "hash1: $hash1{$key} hash2: $hash2{$key}\n"; } } --------------------------------- Frank Wiles <[EMAIL PROTECTED]> http://frank.wiles.org --------------------------------- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]