Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2024-04-23 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found