That's not what you want to do. If you write over the file with something smaller, you will still have old stuff left over at the end. What you should do is write to a NEW file and then move the new file over the old file. You can use "perl -i". See "perldoc perlrun" for details.