use warnings; my $Timer; my $Display; # This is the Canvas where the widgets are drawn {main code skipped over} sub showProblem { $Timer = $Display->after(shift, sub { $Globalvariable = blah blah blah... $Timer->cancel(); }); }