Something like:
foreach (keys %hash1) {
next if $hash1{$_} eq $hash2{$_};
print $hash1{$_} $hash2{$_}\n;
}
On Wednesday, October 16, 2002, at 08:54 AM, Egleton, Gary wrote:
Hi,
can any one point me at how to compare two hases.
ie
hash1
1 abc
2 def
.--[ 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
]
Subject:Re: comparing two hashes
.--[ Egleton, Gary wrote (2002/10/16 at 14:54:57)
]--
|
| Hi,
|
| can any one point me at how to compare two hases
; # now
prints extra keys not in both hashes
}
-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 16, 2002 11:25 AM
To: Egleton, Gary
Cc: [EMAIL PROTECTED]
Subject: Re: comparing two hashes
Something like:
foreach (keys %hash1
';
This sets hash1's value at key '2' to 'foobar'.
Or am I misunderstanding your question?
-
Frank Wiles [EMAIL PROTECTED]
http://frank.wiles.org
-
| Subject:Re: comparing two hashes
|
| .--[ Egleton, Gary
On Wed, 2002-10-16 at 09:54, Egleton, Gary wrote:
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
Gary Egleton wrote:
Hi,
Hello,
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
Gary Egleton wrote:
can any one point me at how to compare two hases.
You can also use a CPAN module, e.g.
use Data::Compare;
if (Compare(\%hash1, \%hash2)) {
# hashes are equal
} else {
# they arent
}
Greetings,
Janek
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional