Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a file in READ/WRITE format

Status
Not open for further replies.

naq2

Programmer
Aug 3, 2004
74
FR
I'm don't really know how to open for readding and writing at the same time... Usually, I used to open it in "append" mode and it was fine for me.

What I exactly want to do is:
Replace the $i line without altering the lines before and lines after.

If you have any simple way of doing so... please let me know.
Thanks in advance.
 
1. Open the file for reading.
2. Read the contents into an array.
3. Close the file.
4. Modify the appropriate array element(s).
5. Open the file for writing.
6. Write the array contents to the file.
7. Close the file.

Probably a good idea to make a backup of the original file
somewhere before step 5.
 
Ok, thanks...

This is what I would have probably thought if I had the idea clear... that is not the case today.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top