in reply to Another variable scoping oddity
You have created a closure.
At the time the function is parsed and compiled, the second my's compile time effects have taken place; the closure is therefor bound to the second lexical called $k. Regardless where and when you call the function, the $k inside the function always refers to the second $k.
At runtime, at the time of the first call to the function, no value has yet been assigned to that one. Meanwhile, the associated print refers to the first $k.
Makeshifts last the longest.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Another variable scoping oddity
by Roger (Parson) on Nov 12, 2003 at 06:36 UTC |