The easiest way may be the new module Tie::File.
Stat the file, if it's too big or will be soon
(say with what you are about to append), shift/splice the array, et voila!
(I'd simply remove n entries each time, instead of calculating for exact size).
You can predict size with a stat / -s and then adding length($message).