i *should* use "use" or "require", but since i'm doing some quite messy namespace-stuff (plugins, global dbh's, eval-ed strings that call subs, etc.), that would be a major pain in the behind.

Moving this stuff into an external file will not make your code less messy. In fact, I think it will make it more so. Most of the advantage of modules is not having separate files, but having clean interfaces. I'd even venture to say the clean interface is much more important than the separate files.

Here's what I recommend: clean up the interfaces between your core functions and main code, move the core functions into a package, and then think about making a module out of that package. It may seem like a daunting task, but just pick away at it, and, before you know, it will be tolerable and clean.

If you have any questions about how to clean up something specific, you can always post a new question at the Monastery. If there's anything the Monks can do, it's rework a piece of code. :^)


In reply to Re: cleaning up code with "do" ? by revdiablo
in thread cleaning up code with "do" ? by schweini

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.