in reply to help me speed up badly designed perltk code?

I have no clue what you are trying to do, by destroying your mainwindow. It is possible,and probably easy, to make Tk work fast for editing a bunch of files, but you need to explain in more detail what you need to do.

As to giving you some clues, based on guessing what you want, there is the toplevel window, for creating and removing windows quickly.

#!/usr/bin/perl + use Tk; + $mw = MainWindow->new; + $mw->title("MainWindow"); + $mw->Button(-text => "Toplevel", -command => \&do_Toplevel)->pack( ); + + MainLoop; + sub do_Toplevel { + if (! Exists($tl)) { + $tl = $mw->Toplevel( ); + $tl->title("Toplevel"); + $tl->Button(-text => "Close", + -command => sub { $tl->withdraw })->pack; + } else { + $tl->deiconify( ); + $tl->raise( ); + } + }

I'm not really a human, but I play one on earth. flash japh