From perldoc perlsub, section: Temporary Values via local()

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
      Feh! Don't spread that garbage here. =P It is a trademark and is thus limited to protecting using the mark for the promotion of products; and even then only within their major product category. If you aren't selling anything, it is just a word. Don't call it a copyright, that is for complete works. And a service mark is for branding a company or service rather than a product. You can't call any consumable "Coke" but a few hundred years of steel workers are still allowed to call the molten mass of coal and iron "coke".

      And now, back to your regularly scheduled perl programming, already in progress...

      As if I didn't know it was a joke, dad =P

      --
      $you = new YOU;
      honk() if $you->love(perl)

        Um, it's a joke, son...