One thing that I would definitely do is to put all of this logic into one – possibly two – Perl modules which are tasked with maintaining the entire storage system. I would also "future-proof" the design by prefixing the file with a file-version identifier so that the file, whatever it turns out to be, is "self-describing" to programming that is in the know ... programming which occurs in exactly one place or set of places.