LI NGOK LAM wrote:

> >
> > You will probably want to open the file with a mode of "+<".
> >
>
> Yes and thank you! That does what I want now. Thank you very much !!
>
> But I found new problem now. I did what I want if I try on a bitmap file,
> but for text file, my new contents will overwrite the whole file, what's
> that about

That's right.  And if you add two and two you will get four mo matter how
badly you want five.

Text is sequential.
Character data, including that of which text is composed, may be treated as
simple binary arrays, in which elements can be addressed at any point, but
only by byte-for-byte replacement of existing data.

Read ["<filename"],
Write [">filename"]
and Append [">>filename"]
modes are sequential, text-oriented modes.  None of them allow for in-place
replacement of data.

Binary ["_<"] mode does allow for replacemnt in place.  This replacement must
be on a byte for byte basis, though.

You can't have your cake and eat it too.  If you are replacing data
byte-for-byte, you can edit any kind of data in-place.  If you need the
flexibility to replace data with data of another length, add new data
anywhere but at the end, or delete data anywhere but at the end, you MUST use
sequential, mode, which will clobber the file being written to.

Perl does have in-place editing modes, which may abstract the
copying/renaming process somewhat. Nevertheless, the same work is done under
the surface.

Joseph

>
> or where I should refer to now?
>
> >
> > --
> > Paul Johnson - [EMAIL PROTECTED]
> > http://www.pjcj.net
> >
> >
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to