in reply to Catching the death of a weak reference

You could presumably put your own routine in place of magic_killbackrefs via XS; you'd need to do something like
int handle_killbackrefs(pTHX_ SV *sv, MAGIC *mg) { /* loop stolen from magic_killbackrefs, with * whatever you need to do to for each svp[i]. */ /* afterward, */ return magic_killbackrefs(sv, mg); } extern MGVTBL PL_vtbl_backref; PL_vtbl_backref->svt_free = MEMBER_TO_FPTR(handle_killbackrefs);