in reply to Organizing personal perl library (AKA, personal CPAN)
It sounds like you may have useful modules buried amidst your various projects. While a source code repository is a good thing (for many reasons beyond organization!), you may just need to be a little more structured in how you break out the reusable bits.
My suggestion is to package reusable bits as modules as if you were going to release them to CPAN, even if you don't release them to CPAN. Put them under a "Local::" or "Username::" namespace and install them locally. Keep a directory of all those reusable bits separate from your projects that use them. E.g.
/home/yourname /modules /Local-Module-a /Local-Module-b ... /projects /project-1 /project-2 ...
(That works well in a repository like subversion too -- within each module and project you can have subdirectories for branches, tags, etc.)
The trick is to do it as you write them. Rather than hack up something for your current project, when you recognize that you're writing something more general, stop and pull it out into a separate module.
Creating a basic installable module distribution is pretty easy. See How to make a CPAN Module Distribution for examples. Tools like ExtUtils::ModuleMaker and Module::Starter make it really easy to create a new install-ready distribution.
ExtUtils::ModuleMaker has a nice menu system that pretty much walks you through all the steps. (Note: If you use it, go into "Directives" and set the "Compact" option to 1 -- you'll thank yourself later.) Then just fill in your code to the boilerplate .pm file in the directory it creates, run perl Makefile.PL and make, make test and make install.
Once you've done that once or twice, that will cost you about 2 minutes or less once you've identified that you've got a reusable bit of code. (More, of course, if you document, write proper tests and so on.)
Of course, you'll still need to figure out how to package them with any projects that you are handing off. There's been some discussion of that here, but many projects seem to either put module dependencies on CPAN, or package them with an application under a lib directory with the rest of the project. (If you want to use CPAN, but the modules aren't really useful for others, release them under a namespace with your username as the first part to signal that they aren't really for public consumption.)
Even if you don't want to go to the trouble of writing them up as modules, keeping reusable .pm files in nicely organized directories and adding them to your PERL5LIB might be an easy way to help you find stuff later.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|