use Tk; use strict; my $pathToMyself = $0; my $mw = MainWindow->new(); my $bt = $mw->Button(-text=>"Restart", -command=>\&restartMe)->pack(); MainLoop; sub restartMe { print "Restarting $pathToMyself...\n"; exec( $pathToMyself ); }