Just a comment. BTW I agree with the above comments that you whould avoid globals <e>especially</e> in long scripts.

But as and aside regarding use vars and  our declarations. I don't believe they are quite equivalent. This might be splitting hairs, but a use vars declaration gives a package variable while an our declaration gives a global disguised as a my variable. This means the scoping is lexical for our variables. The following code

&decl(); print $variable; sub decl { our $variable = 1; }
would not compile under strict. $variable is out of scope by the print statement. A use vars qw($variable); line would work however.

Another implication, if you are using packages to give different name spaces in the same file, a declaration like...

package one; use vars qw($thing1); our $thing2; #stuff; package main; print "$thing1 and $thing2";
might not do what you expect. For example not run under strict. The vars variable $thing1 is a package variable, not available to the main package without a $one::thing1 type address. $thing2 however, the our declaration <e>is</e> available to the main package. It's scope is the same as my so is file wide in this sample.

I didn't get this when I first started using <cod>our</code> so I just wanted to throw it there since it seems to apply to this thread.

Ira,

"So... What do all these little arrows mean?"
~unknown


In reply to Re: Understanding why strict prevents a use of local by IraTarball
in thread Understanding why strict prevents a use of local by c

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.