#!/usr/bin/perl -w use strict; use warnings; use Tk; my $mw = MainWindow->new(); $mw->Button( -text => 'Start', -command => \&start_process )->pack; $mw->Button( -text => 'Stop', -command => \&stop_process )->pack; MainLoop; sub start_process{ my $count = 0; while ($count < 10) { print $count; sleep 1; $count ++; } } sub stop_process{ #stopping the process }