I would normaly go with
gri6507's solution,
$mw->update() will display the main window and return when any events are done (there should be very few with out any user interaction).
An alternative is to use
Tk::after, from it's POD:
- $widget->after(ms,callback)
-
In this form the command returns immediately, but it arranges for callback be executed ms milliseconds later as an event handler. The callback will be executed exactly once, at the given time. The command will be executed in context of $widget. If an error occurs while executing the delayed command then the Tk::Error mechanism is used to report the error. The after command returns an identifier (an object in the perl/Tk case) that can be used to cancel the delayed command using afterCancel.
The downside is you will either have to break up your proccessing into chunks, so that Tk can be given controll to update it's window, or you will still need to call
$mw->update() to do that your self.