hey,

if any of you would care to assist me...

im writing a script which opens itself does a bunch of modifications and then writes the changed code to another file.

first, it opens itself, reads certain lines into an array, then writes these lines to another file, then opens that file, does some more modifications (it does them on the file instead of the array because the code needs to pass over all the data at once , so i unset $/) and then i want it to write that output back to the file, but i cant write it back to the same file because if the file is opened for updating it, the file gets messed up, and if its opened for the other kind of read-write, then it gets clobbered...i know i could create a third file as a temp file but i'd rather not..so what i really need is either a way to traverse an entire array in one step so i dont have to write it to a file before everything is done, like unsetting $/, but for an array, or a way to solve the problem otherwise without creating a third file.

thank you.


In reply to file editing/writing by Anonymous Monk

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.