Salutations , O Great and Wise Monks . I as a total apprentice seek your wisdom and knowledge. On the following problem : I have two files (xname1 xname2 ) the information in those files is structured like this xname1 :

FBgn0041711 yellow-e FBgn0038150 FBgn0041711 yellow-e FBgn0039896 FBgn0041711 yellow-e FBgn0032601 FBgn0041711 yellow-e FBgn0038151 FBgn0041711 yellow-e FBgn0041713 FBgn0041711 yellow-e FBgn0041710 FBgn0041711 yellow-e FBgn0041712 FBgn0041711 yellow-e FBgn0034856 FBgn0041711 yellow-e FBgn0038105 FBgn0041711 yellow-e FBgn0041709 FBgn0041711 yellow-e FBgn0035328 FBgn0041711 yellow-e FBgn0004034 FBgn0032283 CG7296 FBgn0042110 CG18765 FBgn0039328 FBgn0042110 CG18765 FBgn0039325

the information in the other file is structured in the same way xname2 :

FBgn0041711|FBtr0082757 F dme-miR-iab-4-5p MIMAT0000412 25 + seven_m8 FBgn0041711|FBtr0082757 F dme-miR-2280-3p MIMAT0011787 51 +seven_A1 FBgn0041711|FBtr0082757 F dme-miR-955-3p MIMAT0020847 69 e +ightmer FBgn0041711|FBtr0082757 F dme-miR-4957-3p MIMAT0020176 43 +seven_A1 FBgn0039896|FBtr0089115 F dme-miR-2280-3p MIMAT0011787 9 s +even_A1 FBgn0039896|FBtr0089115 F dme-miR-4943-5p MIMAT0020151 12 +seven_m8 FBgn0041711|FBtr0082757 F dme-miR-2280-3p MIMAT0011787 51 +seven_A1 * FBgn0039328|FBtr0084849 F dme-miR-977-3p MIMAT0005493 92 s +even_A1 FBgn0039328|FBtr0084849 F dme-miR-967-5p MIMAT0005482 92 s +even_A1 FBgn0039328|FBtr0084849 F dme-miR-4943-5p MIMAT0020151 143 + seven_m8 FBgn0039328|FBtr0084849 F dme-miR-4967-5p MIMAT0020192 99 +seven_m8 FBgn0039290|FBtr0084805 F dme-miR-2501-5p MIMAT0012216 583 + eightmer

So what I strive to achieve is the following thing . I need a loop that goes trough every line in the first and second documents (array list) and if it finds a matching Fbgn from the first document to the second document (be it the firs one or the second one FBgn in a line) to paste the dme-mir only or the whole line below (preferably the dme-mir only) the found match. It should look something like this :

FBgn0041711 yellow-e FBgn0038150 FBgn0041711|FBtr0082757 F dme-miR-iab-4-5p MIMAT0000412 25 + seven_m8 FBgn0041711|FBtr0082757 F dme-miR-2280-3p MIMAT0011787 51 +seven_A1 FBgn0041711|FBtr0082757 F dme-miR-955-3p MIMAT0020847 69 e +ightmer FBgn0041711|FBtr0082757 F dme-miR-4957-3p MIMAT0020176 43 +seven_A1 FBgn0041711|FBtr0082757 F dme-miR-2280-3p MIMAT0011787 51 +seven_A1 * FBgn0041711 yellow-e FBgn0039896 FBgn0039896|FBtr0089115 F dme-miR-2280-3p MIMAT0011787 9 s +even_A1 FBgn0042110 CG18765 FBgn0039328 FBgn0039328|FBtr0084849 F dme-miR-967-5p MIMAT0005482 92 s +even_A1 FBgn0039328|FBtr0084849 F dme-miR-4943-5p MIMAT0020151 143 + seven_m8 dme-miR-4943-5 +p

The last line is the other variant with the dme-mir only . I'm really sorry if I didn't make it clear and for my noobish question. All help will be greatly appreciated! Thanks again and have a nice day.


In reply to Duplicates in arrays and add values by Waterdrake

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.