Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Importing variables (not functions) from in-file packages

by puterboy (Scribe)
on Feb 12, 2014 at 19:14 UTC ( #1074669=note: print w/ replies, xml ) Need Help??


in reply to Re: Importing variables (not functions) from in-file packages
in thread Importing variables (not functions) from in-file packages

Cool. It does indeed work. But why does strict cause the compiler crap-out on $globalVar but accept $::globalVar. Isn't $globalVar (when not defined as a lexical variable) just a shortcut for the (main) package variable $::globalVar aka $main::globalVar? Or is the "shortcut" only known at runtime...


Comment on Re^2: Importing variables (not functions) from in-file packages
Re^3: Importing variables (not functions) from in-file packages
by Anonymous Monk on Feb 12, 2014 at 19:55 UTC
    Because that is what you asked it to do with  use strict 'vars';
Re^3: Importing variables (not functions) from in-file packages
by AnomalousMonk (Abbot) on Feb 12, 2014 at 20:29 UTC
    Isn't $globalVar (when not defined as a lexical variable) just a shortcut for the (main) package variable $::globalVar aka $main::globalVar?

    It is a 'shortcut' only if you make the lexical declaration
        our $globalVar;
    Then if the first access of the package variable  $globalVar is after the declaration, everybody's happy; otherwise, the variable name must be fully qualified. See our.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1074669]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-10-02 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (61 votes), past polls