Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Help needed understanding global variables in Perl

by shotgunefx (Parson)
on Mar 05, 2002 at 11:05 UTC ( #149327=note: print w/replies, xml ) Need Help??


in reply to Re: Help needed understanding global variables in Perl
in thread Help needed understanding global variables in Perl

A clarification on the following point.
The closest thing to a global variable in perl is a variable that lives in main::'s symbol table. This is because whenever a variable is referred it is always looked for in main::. But this is only a last resort,

This is not true. If you are not in main:: it will not look in main for a variable unless you use our $var and then it's still only I belive in the current lexical scope.
# Prints nothing. perl -e '$var = 'value';package FOO; print $var' #prints "value" perl -e 'our $var = 'value';package FOO; print $var' #prints "value" perl -e '$var = 'value';package FOO; print $main::var'


-Lee

"To be civilized is to deny one's nature."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://149327]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2017-04-29 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.