use Carp 'croak'; sub UNIVERSAL::AUTOLOAD { my($m) = $UNIVERSAL::AUTOLOAD =~ /::(\w+)$/; croak "Undefined subroutine &$UNIVERSAL::AUTOLOAD called" unless $m eq 'global'; print "this sub really is global\n"; } global(); { package foo; global(); } __output__ this sub really is global this sub really is global