A `local' modifies its listed variables to be "local" to the
enclosing block, `eval', or `do FILE' --
and to any subroutine called from within that block.
But knowing this is not enough, you have to think about the implications as well!
Recently I had a hard time to find a bug in a Tk application.
Part of the application scans large textfiles.
If a certain string is found, it is inserted into a listbox.
During that scan, you should be able to use the application in a normal way.
This is easyly achieved, you just have to do a $MW->update() frequently and all Tk events will be processed.
So far no problem.
But when you change the input line separator $/ to something really weird for those scan,
you've got a PROBLEM!
Even if you do it local!
Because local means local to the block and all called subroutines, of which $MW->update() is one,
and all subs called during the event processing also.
So every reading from files done somewhere in the application went gaagaa during those scans.
I spent hours!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(crazyinsomniac) Re: Fun with local :-(
by crazyinsomniac (Prior) on Mar 17, 2001 at 05:19 UTC | |
by extremely (Priest) on Mar 17, 2001 at 06:43 UTC | |
by myocom (Deacon) on Mar 17, 2001 at 06:59 UTC |