my @diff = grep { !exists $old_gp{$_} } keys %new_gp;
push @diff, grep { !exists $new_gp{$_} } keys %old_gp;
####
my (%foo, %bar);
# Populate %foo and %bar
# Keys present in only one hash
my @only_in_foo = grep { ! exists $bar{$_} } keys %foo;
my @only_in_bar = grep { ! exists $foo{$_} } keys %bar;
# Matching keys which have differences in values
my @kv_different = map {
if (exists $bar{$_} && $bar{$_} ne $foo{$_}) { $_ }
else { () }
} keys %foo;
# Matching keys and values
my @kv_equal = map {
if (exists $bar{$_} && $bar{$_} eq $foo{$_}) { $_ }
else { () }
} keys %foo;
####
my (@only_in_foo, @kv_different, @kv_equal);
foreach (keys %foo) {
if (exists $bar{$_}) {
if ($bar{$_} eq $foo{$_}) {
push @kv_equal, $_
}
else {
push @kv_different, $_
}
}
else {
push @only_in_foo, $_
}
}
my @only_in_bar = grep { ! exists $foo{$_} } keys %bar;