I tried making an array out of each element or cluster and then tried using =~ and if it matches, then push both in a new array and then delete the duplicates from that array.But,I am not able to get the output. This is my original output,that I need to edit. @output = (23 24 25 26 27 28 30 31 32 33 39 44 45 46 47 48 49 50 51 68 \n 44 45 46 47 48 49 50 51 68 69 70 \n 75 77 78 79 80 81 82 83 84 85 87 89 103 104 105 106 107 110 \n 103 104 105 106 107 110 112 113 122 123 125 \n 110 112 113 117 118 119 120 122 123 125 127 128 129 130 131 132 133 134 136 137 140 144 148 149 \n 117 118 119 120 122 123 125 127 128 129 130 131 132 133 134 136 137 140 141 142 144 148 149 \n 117 118 119 120 122 123 125 127 128 129 130 131 132 133 134 136 137 140 144 148 149 157 \n 148 149 151 152 153 155 157 159 168 170 172 \n 151 152 153 155 157 159 168 170 172 173 174 175 192 193 \n 163 164 263 264 265 266 267 269 270 273 \n 172 173 174 175 192 193 194 195 196 197 198 \n 183 184 204 205 206 207 208 209 210 211 228 \n 204 205 206 207 208 209 210 211 228 229 230 231 232 247 \n)