You don't declare global variables, like you do
my variables, or even
local variables. You didn't declare them with
use vars, and you don't declare them with
our. Global variables spring into existence upon being used; they are not dependent upon mere mortals for their existence.
The only thing that our buys you is the ability to refer to a global variable without its package specifier. If you can accomplish what you need to with lexical variables, you should use them. If you need globals, you may use them. If you use globals, you may use our to save typing the fully-qualified name every time you reference them. But that is all it buys you. our did not introduce any new kind of variable (nor did use vars).
You could do it with use vars, but that (as the docs you quoted said) doesn't give you as tight of control over where the global can be referenced as a familiar. It is, according to its own docs, obsolete.
Caution: Contents may have been coded under pressure.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.