in reply to Comparing array contents to DB contents
This assumes the named fields are always present in both the $vals and $row hashref...my @keylist=qw(field1 field2 field3); for $row (@$list) { $id = hashcmp($row,$vals,@keylist) ? $row->{id} : insert_row($vals) ; } sub hashcmp { my ($a,$b,@keylist) = @_; for(@keylist) { next unless $a->{$_} || $b->{$_}; # both undef return 0 unless String::Approx::amatch($a->{$_},$b->{$_}); } return 1; }
|
|---|