in reply to Stashing a Package Variable by Reference
... after which both strict and warnings should be re-enabled.
The assignment doesn't produce any warnings. It's the later use of the variable that does. Note that this warning can be avoided if the variable is created at compile time from a different package than the one in which it resides. (See vars.)
As for strict, you can let Perl re-enable strict by placing the no strict 'refs'; inside of curlies.
$ perl -le' use strict; use warnings; BEGIN { my $pkg = "Foo::Bar"; my $var = "s"; no strict "refs"; ${"${pkg}::$var"} = 123; } print $Foo::Bar::s; ' 123
|
|---|