If you are using our to access data within one package only, why are you making it a global when you could trivially make it a lexical?

Here are the rules I follow. I use my unless there is a specific reason not to. I will use our for certain standard globals that need to be global, such as @EXPORT_OK. When I need to share variables across multiple files I try to use Exporter to export it from one place to all of the places that need it. 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 used to not use our for those standard globals. Instead I used to just initialize them before my use strict line. But it has been so long since anyone I care about has been using Perl 5.005 that I no longer worry about that.


In reply to Re^6: 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.