in reply to Verify database consistency after merge
...snip lots of other code...use strict; # the obligitory use warnings; # use strict and warnings use Digest::MD5; my $makedigest = \&digestit; my %ldb = $makedigest->(\%lemployee, $lsth); my %rdb = $makedigest->(\%remployee, $rsth);
My main reason for doing it this way is that I have NO unique key, so I rely on several columns together to provide me with a unique key. Because the above code is incomplete its probably useless, but the concept is there. Once you have your two hashes ( before and after ) compare the sums.sub digestit { my $dbhash = shift; my $sth = shift; my %newdbhash = (); while ( $sth->fetchrow_arrayref ) { my $keydata = Digest::MD5->new; for my $key ( keys %{$dbhash} ) { %{$dbhash}->{$key} = '' unless ( defined(%{$dbhash}->{$key}) ); } $keydata->add(%{$dbhash}->{$_}) for @key; my $digest = $keydata->hexdigest; $newdbhash{$digest} = {%{$dbhash}}; } return %newdbhash; }
|
|---|