I always use the following thing.. Is that better/worst is just different?

Well, actually I use my File::PlainIO module, which has an update(coderef) method. That chooses the best approach (slurping or file buffers) and receives an update function as first parameter, so it becomes $file->update($mysub)., where $mysub = sub {...};

Theoretically, you can read and write in the same file, but that isn't such a good idea. In fact, you can write over the part you just needed to read. That's why I use a temporary file and write the data in there first.

About my File::PlainIO module. If you want to use it, I can e-mail you the latest version. I've been editing my modules a lot over the past week, and I had some fixes, which are not included in the download at my website right now.

The perldoc of my File::PlainIO is online available [url=http://www.codingdomain.com/cgi-bin/frameset.cgi?url=perl/downloads/x-modules/file_plainio.html]here If you want to use it, I'd be onnered. Or, just let me know what you think of it or what I can change.

I created this module so I don't code all io 10 times. The array's returned can defaultly have a certain size (and "" assigned for all missing elements, not found in the file). Locking is done automatically. \n chars are already chomp-ed The program can automatically die with an error. Also, I introduced an update function for fast changes. (saves you a lot of coding with sysopens) here is an example: