Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I won't read through the tutorials to learn what that last line does. I recognize all the operators, but can't be sure what it does without looking stuff up. The use of "&&" confuses me. It looks like some boolian structure that I used to know how to use, or maybe it's an ordinary logical "and", but I'd like to see parentheses in that case because I never remember the order of operations of things.

I recognized the hash, but I'm unsure about the the use of "exists". I guess it's being used for the 1 or 0 value, but I don't think that's how it's usually used. I wouldn't use hashes when teaching something not related to hashes. I've only used them once when I wrote Varstructor, which had to parse code that might contain hashes, and maybe another time for that duplicate elimination trick.

In the second block of code, I just didn't get the point. Maybe I didn't try hard enough, but a better explanation would have helped.

No matter what code you use in an example, it helps to explain what it does.

...*any* single one of those 11,000 lines can modify that global value. Therefor, when your global has the *wrong* value, you have problems finding it, because you must examine 11,000 lines of code.

After I posted that reply I realized that might the person's point, but he mentioned having to step through the code with a debugger, which wouldn't be necessary. Is it really so hard to search the code for the variable in question? Even Wordpad, which I'm still using for now, could do that. With globals, you don't have to check to see if you passed the value on to another routine. You merely search for a variable by name.

As I mentioned in another thread, if you change plans and want to call a variable that was lexically scoped a few routines ago, things get complicated.

I find the arguments in this thread to be lacking substance. The effort it takes to properly scope variables, which often requires a different code structure, outweighs the problems I've encountered using globals. Globals mean less planning ahead, EASIER debugging, and, using the definition of "safe" that people have used with me, safer code.

In reply to Re^3: Global variable vs passing variable from sub to sub by Wassercrats
in thread Global variable vs passing variable from sub to sub by kiat

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (8)
    As of 2018-04-20 15:43 GMT
    Find Nodes?
      Voting Booth?