*laughs* I am for intelligently-designed limited use of goto statements in non-production code. Just so you know.

As for global variables making sense ... Yes, it is theoretically possible that a global variable is the "best" way to design a solution to a given problem. However, it has been my experience (and the experience of every skilled programmer I have ever talked to about this issue) that there has always been a better design solution.

Now, if you're talking about hacking something together really quickly ... sure. Use all the globals you want! But, if you're working on designing something intended for longterm use, especially in OO, you'd have to talk really fast to convince me that globals are the best design solution.

Just so you know, the solution I gave you involved what are called "symbolic references". They are, like globals and goto statements, considered to be almost universally bad. In fact, one monk has (had?) a sig that said you should never use symrefs unless you know why you shouldn't use symrefs. I've used symrefs in production code exactly once. In 6 years of programming Perl. Take that for what it's worth. (I've never needed to use goto in production code, and I've spent weeks encapsulating global variables into Exporter-driven modules.)

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

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to Re5: Accessing Other Globals? by dragonchild
in thread Accessing Other Globals? by Foo::Bar

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.