in reply to Caching problem?

Without seeing the program, I can see two possible causes:

  1. Your program is reading (what it thinks is) the new data from the old file through an open file handle to the old file. If you keep a file handle open to a file, some operating systems allow you to unlink or rename the file to a new name and still read the data from it through the filehandle. This is only testable by inspecting your program and looking at the control flow. I recommend ripping out all CGI-related functionality and first making sure that the program works correctly from the command line, updating the file and displaying the correct data set.
  2. Your browser caches the data and displays the old data. This should be easily verified by reloading the page from the browser.
  3. You're using some data caching and a persistent environment like mod_perl. Then you have to update or invalidate your cache as well as updating the file on disk.

A technique which I use fairly often to separate changing the data from displaying the data is to modify the data in one request and then send a Location: http://... redirect header to the page that then displays the (now changed) data. This allows me to nicely separate the two operations, at the cost of an additional HTTP request for every modification.