I'm trying to create a perl script that will automatically fit the player's name to the formation. For example, in my: DR.txt
Arbeloa 200 Carvajal 190 Ramos 180
DC.txt
Ramos 200 Pepe 190 Varane 180
DL.txt
Marcelo 200 Coentrao 190 Arbeloa 180
formation.txt:
DR DC DC DL DR DC DC DL
My expected output from my formation.txt will be:
DR Arbeloa 200 DC Ramos 200 DC Pepe 190 DL Marcelo 200 DR Carvajal 190 DC Varane 180 DC DL Coentrao 190
the first row: DR. Therefore, it will take the name from DR. txt which + is ARBELOA 200 the second row: DC. Therefore, it will take the name from DC. txt whic +h is RAMOS 200 the third row: DC. Therefore, it will take the name from DC. txt which + is RAMOS 200, BUT since RAMOS is already exist in the line up, it wi +ll be filled by PEPE 190 the fourth row: DL. Therefore, it will take the name from DL. txt whic +h is MARCELO 200 the fifth row: DR. Therefore, it will take the name from DR. txt which + is ARBELOA 200, BUT since ARBELOA is already exist in the line up, i +t will be filled by CARVAJAL 190 the sixth row: DC. Therefore, it will take the name from DC. txt which + is RAMOS 200, BUT since RAMOS and PEPE are already exist in the line + up, it will be filled by VARANE 180 the seventh row: DC. Therefore, it will take the name from DC. txt whi +ch is RAMOS 200, BUT since RAMOS, PEPE and VARANE are already exist i +n the line up, it will be blank the eighth row: DL. Therefore, it will take the name from DL. txt whic +h is MARCELO 200, BUT since MARCELO is already exist in the line up, +it will be filled by COENTRAO 190
Any help?

In reply to Football formation by eminempark

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.