in reply to Persistent data storage

Hello ssinha, and welcome to the Monastery!

You are trying to modify a text file in-place, but are using the wrong method. Consider the following extract from the documentation for open:

You can put a + in front of the > or < to indicate that you want both read and write access to the file; ... You can't usually use either read-write mode for updating textfiles, since they have variable-length records.

Here are some strategies you can use:

  1. Open the data file for reading, and a different (temporary) file for writing. Process the first file line-by-line, writing each new line to the temp file. When done, rename the temp file with the name of the data file.
  2. Same as (1) but done implicitly via the -i command switch. See Command Switches.
  3. Open the file, and tie it to an array using the core module Tie::File.

Alternatively, depending on your needs, you may be well-advised to pursue the database solution recommended by sundialsvc4 above.

Hope that helps,

Athanasius <°(((><contra mundum