Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Sub Routine Problem

by koolgirl (Hermit)
on Oct 24, 2008 at 06:20 UTC ( [id://719252]=note: print w/replies, xml ) Need Help??


in reply to Sub Routine Problem

Thank you very much, Monks. The examples of code really helped point out some seemingly obvious mistakes, however, after spending two days staring at code, and half of that time de-bugging the part you think you can "get", your vision becomes decidedly unclear :\

I know I still have quite a bit to learn, and please understand, that being able to de-bug my code efficiently, on my own, is a skill I am strongly striving for, yet apparently very far away from reaching...which is just as annoying as the problem itself, if not more so. I thought the ability to code would be the big hump, however, it seems as though the ability to be able to spot one's own mistakes is the real battle. However, every time ya'll help point things out to me, I do get closer to that point, it just seems as though the road is incredibly long at this level of understanding.

I thank all of you for your time, attention, code examples and the push each reply gave me towards achieving the ability to see my own mistakes. Of course further in my venture I will want to for see them before they are made, but wow, let's not get too far ahead of ourselves on that one! :)

Replies are listed 'Best First'.
Re^2: Sub Routine Problem
by Limbic~Region (Chancellor) on Oct 24, 2008 at 18:02 UTC
    koolgirl,
    One of the most effective things you can do to quickly identify and resolve issues with your code is by adopting a consistent methodology to writing the code in the first place. For that, I would recommend reading what I wrote at Re: Refactoring a large script. If you can avoid introducing the bug then you don't have to spend time fixing it.

    When you do need to start bug hunting, many people like brian's Guide to Solving Any Perl Problem. I personally have my own approach which I haven't bothered to document. Often times the biggest help is being able to visualize what's going on - How can I visualize my complex data structure?.

    Again, I have my own approach but one common technique I employ is generously sprinkled print statements. If you have addressed all the issues raised by strictures and warnings but your code is still not producing the correct output, find out where your assumptions failed using the bi-section method. Pick some point in the middle of the execution of your code to output the values of your data up to that point. It doesn't matter if all the values are right or wrong - you have eliminated half of your code as being the source of the problem. Either pick the middle execution point before or after (depending on the correctness of the data values) and wash/rinse/repeate the process.

    Cheers - L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://719252]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found