$repeat->cancel() if $pid{ex1}{val} >= 65; # to the following... $repeat->cancel() if ($pid{ex1}{val} >= 65); and that seems to work better.