Perturbation approach to constrained electron transfer in density functional theory