Analysis of wave motion in irregular layered media using a finite-element perturbation method