in reply to Read and write files concurrently in Perl
I'm guessing that what you wish to do is insert a record into an existing file. The problem is that the open/read/print/close system works at the physical level, not the logical level. For many operations that is very efficient and just what you need, but on-the-fly inserts and deletes cannot be done with the file in situ. You need a database - that is (one reason) why they were invented.