#!/usr/bin/perl -w use Tk; my $mw = MainWindow->new(-title=>"Demo"); my $HlpBttn = $mw->Button(-text=>"NEW", -command=> sub { make_win(); }); $HlpBttn->pack(); MainLoop; sub make_win { my $win = $mw->Toplevel(-title=>'new window', -height=>10, -width=>50); my $Bttn = $win->Button(-text=>"CLOSE", -command=> sub { close_win($win); } )->pack; } sub close_win { my $thiswin = $_[0]; $thiswin->destroy; }