Hmm..
Why not use REPLACE instead of UPDATE+INSERT?
The only problem with REPLACE is when you UPDATE not all fields in table, but for your example REPLACE is good.
$dbh->do("REPLACE INTO $table SET item_id=?, upc=?",
undef, $item_id, $upc) or die $dbh->errstr;