#!/usr/bin/perl use warnings; use strict; use Tk; my $count = 0; my $top = new MainWindow; my $txt = $top->Scrolled("Text")->pack; $txt->insert('end',"Original stuff\n"); my $button1 = $top->Button(-text => "packForget", -command => sub{ my @w = $top->packSlaves; foreach (@w) { $_->packForget; } &rebuild; })->pack(); my $button = $top->Button(-text => "Exit", -command => sub {exit})->pack; MainLoop; sub rebuild{ $txt->delete('0.0','end'); $txt->insert('end',time."New stuff\n"); $txt->pack; $count++; $button1->configure(-text=>'packForget'.$count); $button1->pack; $button->pack; } __END__