in reply to Re: 'local' for imported variables doesn't work as expected (4 updates)
in thread 'local' for imported variables doesn't work as expected

Tl;Dr , but I don't think there is anything wrong with Exporter it's just the way local works. (See my other post which replicates the problem without Exporter)

It's localizing the symbol NOT the referenced variable.

Otherwise it would be possible to localize lexical variables too.

Update

Demo in the debugger

DB<13> my $x = 42; *b = \$x; {local $b= 666; say "$b = $x"}; say "$b = + $x" 666 = 42 42 = 42

Now exporting typeglobs works because the scalar slot is one level deeper, hence local will operate on the same slot

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

  • Comment on Re^2: 'local' for imported variables doesn't work as expected (1 update)
  • Download Code