in reply to truncate a file from top

I think you should take a look at one of the log file rotation modules on CPAN, such as Logfile::Rotate. No need to redo the work since it has already been done.