I'm assuming the whole length is 18 ft.
Let x and y be the shorter and longer sides respectively.
x + y = 18 (shorter + longer side equals the whole length of the pipe)
2x = y - 2 (2 times the shorter piece is equal to 2 less than the longer piece)
x =

You can solve it simultaneously to find x and y.