in reply to text files
If your file is small, you can read the entire file into an array, then just go back and forth between array elements. Once you've done your modifications, just write everything back out to disk.
-- Brett
Originally posted as a Categorized Answer.
In Section
Seekers of Perl Wisdom