The key to understanding someone else's code is understanding how they thought when they wrote it. Unfortunately if they were not thinking in a very organized or structured way, then it could be hard.

First of all is there any division of this stuff into functions or it it all straightline? If the latter than I would give up on understanding it. 1200 lines straightline is probably not understandable.

Next, did they use strict? If the answer is no, then you have an obvious approach. Just insert a use strict and start repairing errors. As you go you will have every variable pointed out to you, and you can understand each one. You should be able to also notice mistakes, and thinking about which things are and are not mistakes will help you. And if you are asked what you are doing, you can just sigh and say, "You wouldn't believe what I have found in this code..." If they did use it, then your code is probably in better shape, but you don't have this obvious approach.

If the thing is well-factored into functions, then you can just start commenting inputs, outputs, and what the functions do. That should give you the overall structure, but it might take some work.

Finally if you need to write it, ask here for ideas. There are a number of ways to structure running a series of tests, and if you ask you can get some good ideas. (I would use a functional approach with the tests being anonymous functions that take a parsed line and return all necessary useful error messages for the email. Many of the tests would be closures...)


In reply to Re (tilly) 1: Seeking advice about learning another's code by tilly
in thread Seeking advice about learning another's code by E-Bitch

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.