You're going to have to explain how File B relates to File A. I don't want to guess (possibly incorrectly) how adding:

r1 r10 r5

To...

test "r5" test "r1" test "r1" version "10" test "r1" version "11" test "r1" version "12" skip "r1" version "15" test "r4" test "r4" version "10" skip "r4" version "11" test "r3" skip "r3" version "11" test "r10" skip "r10" version "11"

...could result in the addition of these three lines:

test "r5" version "13" ... skip "r3" version "13" ... test "r10" version "13"

Is it a matter of finding the lowest unused "version" number greater than 10? Forget the file handling part... first we need to understand the recipe, or the rules for the change. The insertion issue can't even be addressed until we know how to derive what needs to be inserted, and where.

If this data format has a name, or if you can name its source, that might also help, because things with names or with known sources often have predictable rules.

We might also feel more motivated to help with a question that describes the need more thoroughly, and that shows (with real code) what you've already tried.

Also, if you're wondering why my formatting of your file data looks better than yours, it's because I wrapped it in <code>...</code> tags, per Writeup Formatting Tips.


Dave


In reply to Re: Insert lines in a file by davido
in thread Insert lines in a file by PetreAdi

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.