in reply to Changing a subroutine to a module

If you're not sure about the specifics of creating a module, an intermediate step is to put it in a 'library.' This just means you stick the sub into a separate file and put a 1; at the end of the file. Then, in all of your programs, add a 'require' statement and point to the library file. Then the sub will be available to the program. This is one step away from creating an actual module, but it removes the package and Exporter issues. There is an example here.

When you convert it to a shared sub, you may want to consider using named parameters when you pass in variables. This makes it much easier to change things in the future without breaking a bunch of code that is relying on the position of passed in variables.

There is a good section on named parameters in Effective Perl Programming. Basically, you pass a hash into the sub rather than an array and pull the parameters off as a hash.