You should consider using perl's object oriented module. It allows me to build base classes of code that will be needed by about any script. I can then sub-class the base class, so that the base class can be used over and over again. It's really a great way to get things organized. Here is an article that will be you started: