Good try Guest, but the question specifies that the perimeters are the same, not the areas!
Perimeter of square: 4x
Perimeter of rectangle: 2*(2x-4) + 2*(x-6) = 4x - 8 + 2x - 12 = 6x - 20
So 4x = 6x - 20
2x = 20
x = 10 cm
Perimeter of square = 4*10 = 40 cm
Perimeter of rectangle = 6*10 - 20 = 60 - 20 = 40 cm