In addition to the very wise suggestions already made, I'd like to add an intermediate method, between the two extremes of 'leave it alone' and 'lots of little packages in proper namespaces'.

First divide the functions into logical groups. Graphics in one pile, IPC in another, DB in a third, and don't be afraid to have one pile called 'general' or even 'misc'. If there is some code that might go to CPAN, and some that is proprietary, keep that in mind.

Those piles are reasonable candidates for becoming libraries as they stand, with one extra consideration: You may want to re-arrange them to reduce dependencies.

For example, if you put the function that filters CGI input in the HTML generation module, but an importer module needs to use just that function, and doesn't generate HTML, then that function should probably live in the 'general' library.

Depending on how you build the libraries, you might not have to do weeks of work to make this happen. My first cut at this for my current project involved making modules that were just a big pile of sub foo {...}, and a simple use MyModule gets all of those functions into your namespace. So you can automate some of the conversion process by removing the use you already have, doing a syntax check, and then adding the new use for the individual modules needed. Unless you have thousands of scripts, this shouldn't take weeks. (N.B.: A powerful editor will help. Notepad is not a powerful editor.)

--
Spring: Forces, Coiled Again!

In reply to Re: Code reuse and clean packages by paulbort
in thread Code reuse and clean packages by FoxtrotUniform

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.