in reply to comparing key-value pairs of two hashes

Looking at your code it seems you already know how to pick up array elements. Do you know how to pick up hash elements too? I guess so, then it is fundamentally trivial to perform the remaining test.

As a side note, if you don't already know it, grep is your friend. For example, assuming you do not really want to store the differing keys as "$_ ", then this should be equivalent to your code:

@diff=grep { !exists $old_gp{$_} } keys %new_gp;
And in case you do want to store them that way, then you can chain with a map.

Replies are listed 'Best First'.
Re^2: comparing key-value pairs of two hashes
by Anonymous Monk on Jul 22, 2005 at 10:58 UTC
    There does exist also a hash function called "each".
    while (($key,$value) = each %hash) {
    print "$key => $value\n";
    }
    Hope it will help you a little.