in reply to Re^2: problem with global variables going out of scope
in thread problem with global variables going out of scope
I think of our as a lexically scoped directive similar to no strict 'vars'. The difference is that it only applies to the specified variables.
You think of our as creating a lexically scoped variable which is aliased to a package variable.
I don't agree with you. If the variable was lexically scoped, it wouldn't be possible to use it beyond the end of the lexical scope, as shown in the following code:
{ our $var = 20; } print("$var\n"); # 20
Update: Cleaned up my post.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: problem with global variables going out of scope
by acid06 (Friar) on Mar 29, 2006 at 00:15 UTC |