use warnings; use strict; use Tk; my $num = 0; my $mw = tkinit(); my $button = $mw->Button( -text => $num, -repeatdelay => 25, -repeatinterval => 25, -command => sub{ buttonPressed(); } )->pack(); $mw->MainLoop(); sub buttonPressed{ #this subroutine will be executed if the button is clicked once, #or repeatedly executed if the button is held down. print "."; $button->configure(-text => $num++); }