Perturbation theory of linear systems with applications to structured epidemic models