in reply to Comparing array contents to DB contents

By the way; I always prefer accessing my database rows using hashrefs for the records, to ensure I'm accessing the right fields... If you were to use this method, a partial hash comparison would suffise;

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; }
This assumes the named fields are always present in both the $vals and $row hashref...