use Tk; choice(); # After the widget vanishes # the program continues here ... print "Success!!\n"; sub choice{ $top = MainWindow -> new(); $frame = $top -> Frame() -> pack(); $button = $frame->Button (-text => 'Kill', -command => sub{$top -> destroy()} )->pack(); MainLoop; }