If that solution won't work, then I will "use vars" for the declaration. I never use our for any variables that I've invented within my code. ...
I really don't see why you'd make that distinction. I just use our() for all package variables.
Because if I have to type a variable name in two different files, my typo rate is fairly high. Therefore I really, really want to declare it in one file, and let strict.pm catch my typos everywhere else.

The only time I don't do that is when I'm working with an external API that doesn't give me the option. For example if I were to reinvent Exporter I would seriously think about pre-declaring @EXPORT_OK in the caller's space so that the caller can just access it and will get a useful error for accidentally typing @EXPROT_OK. Were I reinventing it for my own use, then I would definitely do that.

Let me think about it and see if there is any situation where I would use our in my own code. Hmmm.

There is one. And that is for a situation where I want a variable that I only access in one file but I want to use local on it. I'm not sure when that need might come up since it has never yet happened. Of course if Larry would allow local to be used on lexical variables, than that need would go away. (Note, he disallows it because of the potential for confusion, and not for technical difficulty. You can use local in more places than you might think - I like using it on the values of lexically scoped hashes.)


In reply to Re^8: My globals are visable; but undef'ed by tilly
in thread My globals are visable; but undef'ed by Wiggins

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.