A period–luminosity relation for Mira variables in globular clusters and its impact on the distance scale