I would deal with quite this differently to you. For example:
in reply to Production level script template
- Write your documentation in POD, not as comments. That way you can run perldoc scriptname to see the purpose, requirements, etc.
- Put your global variables such as $cmdname and $thread in a singleton object. That means if someone happens to use a local variable called $thread your code won't break.
- Put all the code in a separate module, or at least a file that you can require. This makes your scripts more readable because you don't have to wade through the common code in each separate script. If you find a bug, you only have to change it once.
- Consider using modules such as Log::Log4perl and Email::Send to replace your home-grown equivalents. Less code means less bugs.