You can open a file for read and write at the same time (you probabably want '+<' as the flag to the open call). In addition while the file is open you can seek to any position in the file. See perlfunc (HTMLized nicely at perdoc.perl.org alphabetical listing of functions)