refactoring/improving/tightening/increasing the speed and efficiency of the program

I think you first need to ask yourself which goal you are pursuing. "Refactoring" is usually associated with removing duplicate code and generally improving the maintainability of your code. Efficiency is a different thing entirely (and sometimes opposite, as refactoring things into subroutines increases overhead).

For efficiency, it's critical to figure out real bottlenecks and here profiling tools will help. See Devel::DProf for examples. Once you've identified particular bottlenecks, work on those or post examples to Perl Monks if you're stuck. Don't overlook all the good Tutorials.

There are also some great reference books on these topics. The book that's almost written for your case is "Perl Medic: Transforming Legacy Code" by Peter J. Scott.

For refactoring, for the most part, just look for things that you do over and over again (cut-and-paste stuff) and try to isolate that into separate subroutines. If you're up to it, you could consider pushing some of it into separate modules. (See How a script becomes a module).

-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: Refactoring a large script by xdg
in thread Refactoring a large script by mdunnbass

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.