# Called when Son is no longer externally referenced: sub _free { my( $_son )= @_; my $_dad= $_son->{dad}; if( ! $_dad || ! $_dad->{refs} ) { # Son can die (and take Dad with him) # if there is no Dad (or Dad is also unreferenced): $_son->{dad}= $_dad->{son}= undef; # Break ref cycles! } }