in reply to Extracting data from file and modifying without making change in file.

Strange as it may seem, updating a file “in place” is very often really not what you want to do, for two reasons:

  1. Disk space is dirt-cheap and getting cheaper.
  2. You get two generations of the data:   a clear “before” and “after” version, which you can easily diff.

If you make frequent modifications of the same kind to the data in a file, consider using a template-driven approach to the problem.   Packages like Template::Toolkit are most commonly used to build web pages, but they can do other things too.