It is really hard to imagine how someone could accumulate 6 MB of content into a single perl script and keep it functional (presuming it actually does still function on a system that still uses 5.8.x), let alone maintainable (which, as you are discovering, it is not). No single script should ever get that big. (update: this consideration applies to source code in any programming language, not just perl)

If you do still have a system running 5.8.x, and this script does still run (and does what it's supposed to do) on that system, I would recommend breaking the big script apart into smaller chunks, testing the "decomposed" version on the 5.8 system to make sure it produces the same results as the original, and port the multi-file version to the 5.10 system.

I would expect that in the process of splitting it up, you will find numerous opportunities to refactor the code and eliminate lots of repetitive content. (One sure way of making a script too long is to use the "copy/paste/modify" style of coding, whereby a few lines of code get repeated dozens of times with minor alterations, instead of being written once as a proper subroutine with sensible parameters.) The app as a whole is likely to end up much smaller as a result, and that would be a Good Thing.

One thing is for certain: if the code gets split into different source files, it will be a lot easier to isolate/locate problems.

If the app needs to be around for a while, I would argue that this is the only sane and sustainable strategy -- don't propagate the mistakes of the programmer who left this mess behind. If/when it needs to be migrated again, it'll be easier at that time if you make the effort to refactor it now. Otherwise, you'll just have to face the same problem again later.

One other thought: do you have access to a unix/linux box that you could try this out on? (Would it make sense to do that, or is the process really Windows-bound?) Options and tools for diagnosis, analysis and refactoring might be better in that other environment.


In reply to Re: perl crashes parsing huge script - how to find a line that crashes it? by graff
in thread perl crashes parsing huge script - how to find a line that crashes it? by Anonymous Monk

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.