use Tk; $window = MainWindow->new(-background => 'white'); $window->Button(-text => 'Red', -command => sub { colorset('red') })->pack(); $window->Button(-text => 'Blue', -command => sub { colorset('blue') })->pack(); $window->Button(-text => 'Green', -command => sub { colorset('green') })->pack(); $window->Button(-text => 'Quit', -command => sub { exit() })->pack(); MainLoop(); sub colorset { $color = shift(); $window->configure(-background => $color); }