Popcorn Dave has asked for the wisdom of the Perl Monks concerning the following question:
I've got the following bit of code that is losing the contents of a global array upon it's exit.
$canvas->Tk::bind('<Button-1>' => [sub { my ($e,$x,$y) = (@_); shift; push (@coords, $x); push (@coords, $y); }, Ev('x'), Ev('y')]);
Now it's my ascertion, that since @coords was previously defined as a global, I should be able to keep the information in it without having to return it, correct? The values in @coords should not be clobbered as they're not declared as locals in this subroutine.
Is this one of those I'm gonna kick myself when I get an answer things that I'm just obtusely overlooking?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question of scope
by rinceWind (Monsignor) on May 06, 2002 at 20:26 UTC | |
by Popcorn Dave (Abbot) on May 06, 2002 at 20:42 UTC | |
| |
|
Re: Question of scope
by gav^ (Curate) on May 07, 2002 at 00:53 UTC | |
|
Re: Question of scope
by perrin (Chancellor) on May 06, 2002 at 19:33 UTC | |
|
Re: Question of scope
by stephen (Priest) on May 07, 2002 at 03:43 UTC |