in reply to Re^2: Compare Two Hash refs of Hashes
in thread Compare Two Hash refs of Hashes
# Throw away all keys in old hash that are in new, update keys that ch +anged or are new foreach $key (keys %$new) { if (exists($old->{$key}) { if ($old->{$key} ne $new->{$key}) { updateindatabase($key,$new->{$key}); } delete $old->{$key}; } else { updateindatabase($key,$new->{$key}); } # remove keys that are only in old foreach $key (keys %$old) { deleteindatabase($key); }
That should do it. I assume the hash is very big, otherwise simply deleting and just storing the new hash would be faster and simpler
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Compare Two Hash refs of Hashes
by kalyanrajsista (Scribe) on Jul 16, 2010 at 16:57 UTC | |
by jethro (Monsignor) on Jul 16, 2010 at 23:39 UTC |