Hi, All!

I am plagued, PLAGUED I said, by a bit of perl exceeding 4K lines, where 'use strict;' and '-w' were actively avoided. Not only that, the program is replete w/ symbolic references, vars never accessed, subs called in void contexts, the Holy texts never consulted, no external modules used, and - as a result - the wheel is reinvented poorly more times than the Yankees have World Series titles. Enabling warnings, strict, *or* diagnostics overflow my scrollback buffer.

I want to laugh at it, but my incescent sobbing gets in the way. On top of it all, my girlfriend won't let me bitch about it anymore ( I'm amazed at how much bitching can be fit into a 36 hour period! ).

My query is 'How to I begin knocking this damn thing into shape?'. Of course, some suit made this huge CRAWLING HORROR, nay WOMBAT, mission critical, and the unstable mind that brought this monstrosity into the world is no longer with us ( in more ways than one, RIP! HHOS ). The folks running either end are third generation and don't know how this works, either. Thus, I inherrited this damnable thing and it's the glue somehow.

The thing stinks slightly of PASCAL, too.

Via vgrep, I cannot certainly discern what the script does, but we've proven we need it to function in our e-commerce app. Best I can tell it querries data from a VAXen or two based off of some kind of mangled pre-SQL query from an HTML text box and kicks a job off to some knock-off Win32 app. The inputs and outputs are unclear at best, though analysis of the tcpdump output may reveal something.

Were it elegant but obfuscated, that would be one thing. But it looks so nasty that I think it was writen in M$ Notepad ( except for the length ). I cannot post it, as it may or may not divulge secrets into life, the universe, and everything. So, I am looking for methodology.

So far, I've devised:

  1. enable warnings, and eliminate each.
  2. enable strict, and eliminate each.
  3. follow Camel et al. and follow sane coding practice.
  4. test, fix, test, etc. ( tho I actually have no means to test outside of production at this moment )
  5. reach a critical mass, when there is nothing left to fix and/or remove.
  6. document, document, document, especially as there's none today.

I'm guessing at least a month to fully nurse this thing to what I consider health and continue with my normal duties, but is there an easier way to do it? I don't normally look for a magic spell to fix a problem, but I dunno what else to do. Granted, I have EMACS and the ever so lovely cperl-mode to help me through formatting, highlighting, and the imenu, but I've not tackled something so monsterous and ugly before. I fear fixing it to the point it no longer works.

Advice from the more proficient or those who have tackled something like this is most appreicated and solicited. BTW, I did do a Super Search and some Googling, but nothing truly satisfactory was returned ... did I miss something?

HTH
--
idnopheq
Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.


In reply to Best way to fix a broken but functional program? by idnopheq

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.