Which part is giving you trouble? Break it down into steps, and let us know which step you're unable to implement.

I'm glossing over low level detail so that you can more easily point to the step that is problematic. Once we know which problem you haven't been able to solve, we will know where to provide help. And as you point to the part of the problem you haven't overcome yet, please provide a compact example of code that we can work on with you.

One thing to keep in mind: Imagine you're doing this project with a pen and paper, and that you have no eraser or white-out. This is the situation that you mostly likely find yourself in when dealing with updating variable-width fields in a flat text file. If you were doing it with pen and paper, with no eraser and no white-out, you would take two pages of paper; one with your original information, and one blank. Then you would look at the first line of your original page, and write it down (with any necessary modifications) on the second page. You would repeat this line after line, until you have finished the new page. The new page would then contain a near duplicate of the original, but with the modifications in place. Once you verified that your new page is complete, you could toss out your original page. This is the most straightforward approach, and happens to be very close to how you will accomplish the task programatically as well.


Dave


In reply to Re: Replace a position in a txt file. by davido
in thread Replace a position in a txt file. by BobK1954

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.