If only the top 7 inches is truly loose I would grab it with a needle nose pliers and pull it out. Or you could possibly stick your fingers inside the pipe, spread them to wedge against the inner walls and pull it out. Then go buy a piece of 1.5 inch black ABS pipe from Home Depot and cut off a 14 inch long piece so you have something to hold on to. Smear some ABS glue around the end of the longer pipe and slide it back down in to the roof and into the other pipe. Hacksaw it off flush and put the cap back on.