my %update = map {$_ => $inputUpdate{$_} } grep {$inputUpdate{$_} ne $input{$_} } keys %input; $dbh->do(<<"SQL", undef, values %update, $input{ID}); update TableName set @{[ join ', ', map {"$_ = '?'"} keys %update]} where ID = ? SQL $dbh->commit;