Hello,

simple file read and write question. I've looked it up on the database but could not find what I wanted (or is it that I don't know how or what to look for)... ok... cutting to the chase...

I'm reading a file and when I find a certain line which contains some 'idTag' character I wish to overwrite it. The fact is the lines don't always have the same length. Somtimes... they're longer... sometimes shorter...
Is it possible to do this in a clean way with the read and write operator "+<" without having to introduce a temporary file?

Speaking of which... I can't really seem to find a use for the tmp_file constructor in the IO::File module. If you have an example please let me know.

Thanks in advance!

-Would choke

p.s. I hate it because the more I code, the messier it gets...

2005-09-07 Retitled by Corion, as per Monastery guidelines
Original title: 'Unworthy me!'


In reply to inline file modification by Woodchuck

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.