Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (9)
As of 2024-04-23 10:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found