Actually, I am a newbie in perl.Each element is a cluster of numbers.I want to do two things.First, if all the numbers present in one cluster are already present in another cluster(element here).I want to remove the shorter cluster.
Second,if a number is present in more than one cluster(element),I want to combine those elements to get one big cluster. I want to combine sort them numerically, and remove duplicates.(I know how to sort and have a sub for removing duplicates).
@array = (1 2 3 4 5 6 7 8 10 14 15 20, 7 14 20, 21 22 23 24 40 50);
Actually, these are like arrays within an array.
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
44 45 46 47 48 49 50 51 68 69 70
75 77 78 79 80 81 82 83 84 85 87 89 103 104 105 106 107 110
103 104 105 106 107 110 112 113 122 123 125
110 112 113 117 118 119 120 122 123 125 127 128 129 130 131 132 133 134 136 137 140 144 148 149
117 118 119 120 122 123 125 127 128 129 130 131 132 133 134 136 137 140 141 142 144 148 149
117 118 119 120 122 123 125 127 128 129 130 131 132 133 134 136 137 140 144 148 149 157
148 149 151 152 153 155 157 159 168 170 172
151 152 153 155 157 159 168 170 172 173 174 175 192 193
163 164 263 264 265 266 267 269 270 273
172 173 174 175 192 193 194 195 196 197 198
183 184 204 205 206 207 208 209 210 211 228
204 205 206 207 208 209 210 211 228 229 230 231 232 247)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.