http://www.perlmonks.org?node_id=1065502


in reply to How/can one do save/restore CORE::caller inside an eval?

use v5.12; # This is basically a dummy override that must be performed early # on so that Perl knows we'll be overriding CORE::GLOBAL::caller # later... # BEGIN { *CORE::GLOBAL::caller = sub { CORE::caller(@_) } }; sub foo { say scalar caller; } sub bar { local *CORE::GLOBAL::caller = sub { 'xxxx' }; foo(); } foo(); bar();
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name