You said NOTHING.
I came asking for wisdom, but not any old wisdom that works for you regarding programming style. I asked for something specific. If you want to throw in a bonus answer, have something to back it up relating to the code I posted. If you can't determine that my script is broken, and if you don't know of a better way to accomplish what I want to accomplish, and if it looks like my script will be useful, then there is nothing for you to do except to answer my specific question and thank me for building a debugging and logging tool that every single Perl programmer would have a use for.