my $mw = Tk::MainWindow; # set up all the widgets... $mw->after(0,\&main_loop); sub main_loop { ... }