Some mistakes and corrections.

First of all with strict on you can declare global variables with vars or (in 5.6) with our. (I prefer vars.) Then you don't have to use fully qualified names. In fact doing this is both customary and preferred, because it extends strict's typo checking to global variables, and makes it easier to change what package code is written for. (I would, in fact, assume that anyone routinely using fully qualified names instead of declaring them is simply unaware of how to declare them. Furthermore I would strongly suggest rewriting code which uses lots of fully qualified names without very specific cause.)

Secondly and more importantly, your comment about "implicit namespace" on the $::foo construct is likely to mislead, and may indicate confusion on your part. Writing $::foo does not declare a global in your current package. Instead it declares a global in package main.

How does this work? Well it is simple. Your root namespace is main. In main there is a package main:: which is a reference to the root namespace again. Therefore $::foo is the same as $main::foo is the same as $main::main::foo, etc. (Likewise $foo::bar is the same as $main::foo::bar.) So $::foo is a fully qualified name of a global variable in package main, not your current package.

Therefore there is nothing really implicit about $::foo. And nobody should let the word "implicit" fool you into thinking that it is in the current package. It is in package main.

UPDATE
Added a closing bracket. danger caught the typo.


In reply to Re (tilly) 2: About packages and scopes by tilly
in thread About packages and scopes by nlafferty

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.