use 5.010; use strict; our $FOO; BEGIN { $FOO = 'still foo'; } sub FOO () { 'foo' } BEGIN { *BAR = *FOO; say "in BEGIN (1): \$FOO = '$FOO'"; undef *FOO; say "in BEGIN (2): \$FOO = '$FOO'"; *FOO = *BAR{SCALAR}; undef *BAR; } say defined &FOO ? 'subroutine defined' : 'subroutine undef'; say eval 'my $false; FOO if $false; 1' ? 'FOO allowed' : 'FOO not allowed' ; say $FOO; __END__ in BEGIN (1): $FOO = 'still foo' in BEGIN (2): $FOO = '' subroutine undef FOO not allowed still foo