[sf-perl] oddity with an exported and localized variable

Joe Brenner doom at kzsu.stanford.edu
Fri Nov 27 12:19:22 PST 2009

yary <not.com at gmail.com> wrote:

> Based on the 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*.  A "local" just gives
>        temporary values to global (meaning package) variables.  It
>        does not create a local variable.  This is known as dynamic
>        scoping.  ...

> Emphasis is in the original perldoc. So it looks like a bug to me too.

It seems as though "local" is acting on the symbol table entry
rather than on the thing pointed at by the symbol table.

I tried finding a way to reproduce this without using Exporter
without any luck.  If you use local on something manually
aliased like so:

  *Garbagio::Fantastico::Smellier::stuff = *Garbagio::Fantastico::stuff;

It effects both sides of it as you would expect.

I'm beginning to suspect a bug in some perl optimization for dealing
with Exporter code.

More information about the SanFrancisco-pm mailing list