perl swapped loops