After reading a lot of the responses, as well as some of your other questions, I am coming to a very important conclusion. You are not really designing your code. You're throwing stuff together and getting very confused when it doesn't work.

You really need to get away from the keyboard and put down on paper exactly the steps you want your code to achieve from the user's perspective. Treat your code as a black box and write down the actual specifications. Important questions you need answers to:

And, that's only a subset of the questions you need to ask. Remember - you are telling a being with a 0 IQ exactly what it needs to do. Unless you explicitly tell it, it won't know to do it. If you don't check for a situation, you cannot expect it to do so. So, if you're not sure of what you want to do, you have absolutely no way of telling the computer what to do.

Programming, in my mind, should be 75% design and 25% coding. Both of those tasks should be 40% doing the task and 60% verifying you did the task correctly. So, if you do the numbers, you should really be spending your time as such:

Yes, design is that important. If you have it right, correct coding is a breeze. If you don't have it at all, correct coding is impossible.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.


In reply to Re: Control flow revisited by dragonchild
in thread Control flow revisited by Tricky

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.