sub do_top { if ( !Exists($tl) ) { $tl = $mw->Toplevel; $tl->title('Help'); $tl->geometry("1000x700"); my $frame = $tl->Frame()->pack; my $lab = $tl->Label()->pack; my $ent = $tl->Entry()->pack; #### ANONYMOUS SUB , ANONYMOUS CLOSURE, #### CLOSED OVER LEXICAL $text #### $text is lexical to if {} block in do_top my $text = $tl->Scrolled('Text'); my $push_button2 = sub { $text->insert( 'end', "You pushed button2\n" ); }; $tl->Button( -text => 'Exit', -command => sub { $tl->destroy; } )->pack; $tl->Button( -text => 'Open File1', -command => $push_button2 )->pack; $text->pack(); } else { $tl->deiconify; $tl->raise; } }