Perturbation of invariant subspaces