in reply to In-place editing of files
read up re re "last" etc.
See Simon Carlisle's tutorial, http://juicystudio.com/tutorial/perl/iteration.asp
caution: This reply from newb who may have missed something