Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Note on usage of ours variables and a question

by AnomalousMonk (Archbishop)
on Nov 20, 2019 at 02:13 UTC ( [id://11108924]=note: print w/replies, xml ) Need Help??


in reply to Re: Note on usage of ours variables and a question
in thread Note on usage of ours variables and a question

Variables written ... with a "^" sign and in braces ... are automatically global and available everywhere in your program, without needing to be declared.

So is any fully-qualified package-global (even under strictures):

c:\@Work\Perl\monks>perl -wMstrict -le "{ package Foo; $::bar = 'Baz'; sub p_bar { print $::bar; } } ;; Foo::p_bar; ;; { package Fiz; sub new_bar { $::bar = 'Boff'; } } Fiz::new_bar; Foo::p_bar; ;; $::bar = 'Quux'; print $::bar; " Baz Boff Quux


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-24 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found