Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re (tilly) 2: using 'my'

by tilly (Archbishop)
on Jun 21, 2001 at 21:39 UTC ( [id://90471]=note: print w/replies, xml ) Need Help??


in reply to Re: using 'my'
in thread using 'my'

Actually there are a number of truly global variables in Perl. For instance no matter what package you are in, $ENV, $^W, $_, etc are always the same.

Replies are listed 'Best First'.
Re: Re (tilly) 2: using 'my'
by sierrathedog04 (Hermit) on Jun 22, 2001 at 02:07 UTC
    You are correct. Camel III's glossary says:
    In Perl, only certain special variables are truly global—most variables (and all subroutines) exist only in the current package.
Re: Re (tilly) 2: using 'my'
by chip (Curate) on Jun 23, 2001 at 01:14 UTC
    FWIW, those truly global variables are really all in the main package. The language parser acts as if those global variable names were prefixed with main:: if no package is specified, no matter what package directive is in scope at the time.

        -- Chip Salzenberg, Free-Floating Agent of Chaos

      I know that. An amusing side-effect is that if someone mistakenly tries to throw an our on, say, $_ and they are in any package other than main::, it will not work as they expect.

      This might be considered a bug.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-03-28 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found