Periodic perturbations of Hamiltonian systems