use strict; use warnings; use Tk; my $notified = 0; notify(); continue_processing(); exit 0; sub notify { my $win = new MainWindow; $win->Label(-text => 'Window!')->pack; $win->Button(-text => 'OK', -command => sub{ok()})->pack; Tk::MainLoop(); } sub ok { $notified = 1; Tk::exit(0); } sub continue_processing() { print "Here I am $notified\n"; }