Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Help needed understanding global variables in Perl

by shotgunefx (Parson)
on Mar 05, 2002 at 11:05 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://149327]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2024-04-19 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found