Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Scoping Rules For "our" Variables

by wind (Priest)
on Jun 25, 2011 at 22:38 UTC ( #911414=note: print w/ replies, xml ) Need Help??


in reply to Scoping Rules For "our" Variables

Variable and package names are case sensitive. Simply replace that with $Foo::x and $Bar::x

use strict and use warnings would've alerted you to the problem.

package Foo; our $x = 1; package Bar; our $x = 2; package main; use strict; use warnings; our $x = 3; print "x = $x\n"; print "Foo::x = $foo::x\n"; print "Bar::x = $Bar::x\n"; $x = 4; print "x = $x\n"; print "Foo::x = $Foo::x\n"; print "Bar::x = $Bar::x\n"


Comment on Re: Scoping Rules For "our" Variables
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2015-07-03 21:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (56 votes), past polls