I would not call that "declaring a variable". my $var declares a variable.
our $var; merely instructs perl to allow you to access the global variable $<current_package>::var using the short name. No new variable gets created.
package Foo;
$Foo::var = 1;
print "package var is $Foo::var\n";
{
our $var;
print "same variable using short name is $var\n";
$var = 2;
print "using short name changed to $var\n";
print "package var is now $Foo::var\n";
}
print "I said package var is now $Foo::var\n";
$Foo::var = 3;
print "And now it's $Foo::var\n";
{
our $var;
print "still the same variable using short name is $var\n";
}
If it were my instead of <our> not only you would not access the package variable $Foo:var, but you'd also declare two separate variables in those two blocks!
Jenda
1984 was supposed to be a warning,
not a manual!