While I agree that if you're going to break code into pieces it should be in response to some requirement of the code itself, I sympathise with the too-much-$@%! problem. Perhaps you could try:

a different text editor
This is a navigation problem, not a structure problem. Use an editor with better navigation features: syntax colouring, code folding, jump-to-method, position markers and good search tools will all help.

more POD
I find that well (and consistently) documented code is much easier to get around, especially if it has become unfamiliar. Consider spreading the docs throughout the module, rather than storing them at the end, and adopt a consistent structure to give easy visual cues when hunting for the right line.

question your premises
Why does it have to occupy a single namespace? That suggests a lot of globals or $package::variables, which will very likely have to be rooted out later for one reason or another. Refactor the requirement away.

seek help
Do you really need 4000 lines of code? Sifting carefully through CPAN could cut it down considerably and make it more readable too. Except I'm sure you did that already. And if all else fails:

use mixin;
mixins will let you separate code along whatever lines you like while preserving a single namespace. Schwern's adamantly lower-case module is very easy to use:

Package My::Enormous::Package; use mixin 'My::Filingorsomething'; Package My::Filingorsomething use mixin::with 'My::Enormous::Package';

Hope there's something useful in there. Please excuse if labouring obvious.


In reply to Re: organizing large flat modules? use, require, do, ... by thpfft
in thread organizing large flat modules? use, require, do, ... by halley

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.