I am trying to figure out the scoping rules for "our" variable types. I have the following two questions:
1) If I have decared a variable x in packages Foo, Bar and in the main program, what would be the output of the program below?
2) What would happen if I use the "use strict" option?
Thanks in advance!
# Begin Package Foo
package Foo;
our $x = 1;
# End Package
# Begin Package Bar
package Bar;
our $x = 2;
# End Package
# Main Program
use Foo;
use Bar;
our $x = 3;
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"
$x = 4;
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"