Quasidegenerate perturbation theory applied to the calculation of excitation spectra