Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
$::foo refers to the global variable called foo in the main package, not in the current package.

This works out the same for package main, but it just doesn't DWIM for other packages. The first three times I read through the documentation, I assumed it was just refering to this similarity: clearly, the writers of the Perl parser could tell what package they were in, so they could expand $::foo appropriately. After all, they need to figure out packages for function calls. Instead, it means the same as $main::foo, something that a simple regexp could do for me, if I wanted it to.

Since I thought the point of the package notation was to let the globals stand out with the double colon sigil syntax, I was disappointed to learn that I'd have to hard-code the package name in multiple places: first, in the the package, and second, for all the global variables within that package.

"our" variables solve the hard-coded package name issue, but don't have a special sigil to make them stand out as globals anymore...*sigh*
--
Ytrew


In reply to Re: Perl oddities by Anonymous Monk
in thread Perl oddities by brian_d_foy

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others exploiting the Monastery: (7)
    As of 2014-12-25 18:43 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (161 votes), past polls