use Tk; use strict; use warnings; use Scalar::Util qw/weaken isweak/; use Devel::Peek qw/Dump/;; package Test; sub DESTROY { print "destroying ",shift,"\n"; } package Tk::MyWidget; require Tk::Frame; our @ISA = ('Tk::Frame'); Tk::Widget->Construct('MyWidget'); sub Populate{ my ($self,$args) = @_; $self->SUPER::Populate($args); $self->ConfigSpecs(-attr => ['PASSIVE',undef,undef,undef]); } package main; my $ref; { my $val = 0; $ref = \$val; } bless $ref ,'Test'; my $copy = $ref; weaken $ref; #Dump $ref; my $mw = tkinit; my $w = $mw->MyWidget(-attr => $ref, )->pack; $mw->update; #Dump $ref; print "undefining copy:\n"; undef $copy; print "undefined copy\n"; print "configuring:\n"; $w->configure(-attr => 1); $mw->update; print "configured\n"; print "destroying w:\n"; $w->destroy; $mw->update; print "destroyed w:\n";