in reply to closing window and running sub-routine

The pertinant man page is actually Tk::Wm which tells you how to communicate with the window manager.

Example: (Functional for both XWindows and MS-Windows)

use Tk ; my($mw) = new MainWindow ; my($closeSub) = sub { print "closing\n" ; $mw->destroy ; } ; $mw->protocol('WM_DELETE_WINDOW', $closeSub) ; my($button) = $mw->Button(-command => $closeSub, -text => "Close")->pa +ck ; MainLoop ;
This should also work for 'Toplevel' window created with $mw->Toplevel ; $topLevel->protocol(...) ;