sub some_event { my $cpp_obj = shift; # It's an arbitrary time later. We have no guaranty # the object is still around. return unless $cpp_obj; # I want this to work: if the underlying C++ object # is gone $cpp_obj should return undef in scalar context. # Do stuff that will blow up if $cpp_obj is gone. # ... } sub i_get_called_from_cpp_code { my ($cpp_obj, $time) = @_; my $event = sub { some_event($cpp_obj) }; Scheduler::new_event($time + 10, $event); } #### package Whatever; sub new { my $self = 0; bless \$self } # $self is Whatever=SCALAR(0x9742b30) sub blah { my $self = shift; say $self } package main; my $a = Whatever->new; my $b = $a; # I want to kill $a such that $b is now also undef. How? $a->blah; $$a = undef; # I really want to undefine ALL references to Whatever=SCALAR(0x9742b30) $b->blah; # This should die.