#case 1 => There is common area. merge case my @poly1 = ([0,0],[0,2],[2,2],[2,0],[0,0]); my @poly2 = ([0,0],[3,0],[3,1],[0,1],[0,0]); my @merge_poly12; print ("@merge_poly12\n"); #then I want to print [0,0],[0,2],[2,2],[2,1],[3,1],[3,0],[0,0]; #case 2 => There is not common area, No merge my @poly1 = ([0,0],[0,2],[2,2],[2,0],[0,0]); my @poly3 = ([3,0],[3,2],[4,2],[4,0],[3,0]); my @merge_poly13; print ("@merge_poly13\n"); # then I want to print nothing or only @poly1. #case 3 => There is not common area, But have line, Merge case my @poly1 = ([0,0],[0,2],[2,2],[2,0],[0,0]); my @poly4 = ([0,2],[0,3],[1,3],[1,2],[0,2]); my @merge_poly13; print ("@merge_poly14\n"); # then I want to print [0,0],[0,3],[1,3],[1,2],[2,2],[2,0],[0,0]