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

Scoping Rules For "our" Variables

by rehmanz (Novice)
on Jun 25, 2011 at 22:36 UTC ( [id://911413]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Begin Package Foo
    package Foo;
    our $x = 1;
    # End Package
    
  2. or download this
    # Begin Package Bar
    package Bar;
    our $x = 2;
    # End Package
    
  3. or download this
    # Main Program
    use Foo;
    ...
    print "x without package reference = $x";
    print "Foo x = $foo::x;        # Output should be "Foo x = 1"
    print "Foo x = $bar::x;        # Output should be "Bar x = 2"
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-06-22 21:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.