#!/usr/bin/perl use Tk; use strict; my $count=0; my $window = MainWindow->new; $window->title("My Example"); $window->Label(-textvariable => \$count )->pack; $window->Button(-text => "Start", -command => \&start )->pack; $window->Button(-text => "Stop", -command => \&stop )->pack; MainLoop; ######################################################### my $stop; sub start { while ($count <= 10) { $window->update; $count ++; sleep 1; if ($stop =~ 1) { $stop=0; $count=0; return; } } } sub stop{ $stop=1; }