General Formulation of a Perturbation Theory for Unsteady Cavity Flows