in reply to Re^3: Compare Two Hash refs of Hashes
in thread Compare Two Hash refs of Hashes
Thanks for your efforts
I want to check only particular fields like sdrpretax_vcd taxamt_vcd sdrposttax_vcd dchdetaildate in $old and $new hashes. If there are any differences, I must update the values from $new hash. Please let me know if I can achieve in minimal steps rather than looping around the hashes...
foreach my $TAP ( keys %{$new} ) { ; if ( exists($old->{$TAP}) ) { ; my $hasUpdated = '0'; foreach my $check_field ( qw(sdrpretax_vcd taxamt_vcd sdrpostt +ax_vcd dchdetaildate) ) { ; if ( $new->{$TAP}->{$check_field} ne $old->{$TAP}->{$check +_field} ) { ; $hasUpdated = 1; last; } } if ( $hasUpdated ) { print " Has to update the DB now "; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Compare Two Hash refs of Hashes
by jethro (Monsignor) on Jul 16, 2010 at 23:39 UTC |