use warnings; use strict; eval ' package T; print "A: $x\n"; 1 ' or warn "A: $@"; # => Global symbol "$x" requires explicit package name { no warnings 'once'; *T::x = \"foo"; } # runtime of main! eval ' package T; print "B: $x\n"; 1 ' or warn "B: $@"; # => now works