Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Windows doesn't allow(*) you to delete an open file. So yes, it is required that you create a backup in order to use -i.

However, editing a file in-place isn't that hard to program, even if you need to delete and/or add to the file--provided you only need to process the file serially. Ie. from the beginning to the end, record by record.

The trick is to maintain an in-memory buffer sufficient to ensure that you don't try to overwrite a part of the file before you've read it. If the aggregate additions amount to more than can be held in memory, then using a spill file as the buffer is a little more complex.

Do you have some estimate of the volume of edits/deletions/insertions required?

That said, disks are cheap. The first UK ad google found offered 500GB for 32.

Another approach would be to write the file to a CD/DVD; delete it from the disk; then read it from the optical drive and write to the disk.

(*)It may be possible using obscure backup APIs and special privileges, but that should be considered a very last resort.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Inplace without backup uses no extra disk space? by BrowserUk
in thread Inplace without backup uses no extra disk space? by fusiondog

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (9)
    As of 2019-12-05 15:10 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (151 votes). Check out past polls.