There's been a lot of traffic these days about my, local and our. I read some threads on this topic in this most venerable monastery, and I'm reading Amelia as well (aka the Camel Book, 3rd Edition), so I'm now quite comfortable saying that I do understand how all of this works, at least technically.

This is all fine from the compiler's point of view. But, I want now to focus on the reader's point of view, for a declaration gives hints to the reader about how the code works. Here are my thoughts about use vars vs. our, willfully exposed to your wisdom and enlightened comments|remarks|flames.

So, use vars displays a list of all globals for all to see, right at the beginning of the source file, whereas our highlights the parts of the code where the globals might be altered or referenced.

Now, what would be really cool, IMHO, would be to combine the best of both worlds, i.e. say at the beginning of the source file "Here's the list of all our globals, but no block of code will access any one of them unless it explicitly declares so."...

--bwana147


In reply to Of the meaning of 'our' by bwana147

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.