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.


In reply to Re: Organizing personal perl library (AKA, personal CPAN) by xdg
in thread Organizing personal perl library (AKA, personal CPAN) by srdst13

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.