Thanks for the advice; I'll do that return code checking (I always confuse $! and $? ... maybe I should tatoo them on my arm)
I did think about breaking the script into a "modular" form, but because of the way it will be used (called as an event handler by the error reporting subsystem, via an ODM lookup), I thought it best to keep it all self-contained.