what does it mean that it does not CREATE a local variable?
That's mostly true. Consider these three programs:
$var = "value"; print($main::var eq "value" ? "true" : "false", "\n"); # true
our $var = "value"; print($main::var eq "value" ? "true" : "false", "\n"); # true
As you can see, with or without our, $var refers to $main::greet. No variable is created. The purpose of our is to do no strict 'vars'; on a per-variable basis. Like no strict 'vars';, the our directive is lexically scoped (although the variable isn't).
Remember that I said "mostly true". The exception is when the scope of the our spans packages.
package Test; $var = "value"; print($Test::var eq "value" ? "true" : "false", "\n"); # true
our $var; package Test; $var = "value"; print($Test::var eq "value" ? "true" : "false", "\n"); # false
In reply to Re: OUR declaration
by ikegami
in thread OUR declaration
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |