#!/usr/bin/perl use warnings; use strict; use Tk; my $FILTER_IS_ON = 0; my $top = new MainWindow(); my $c1 = $top->Button(-text=>$FILTER_IS_ON ? 'turn off' : 'turn on', -command => \&turn)->pack(); my $c2 = $top->Button(-text=> 'Go', -state => 'disabled', -command => sub { print "ook!\n" })->pack(); MainLoop(); sub turn { $FILTER_IS_ON = $FILTER_IS_ON ? 0 : 1; $c1->configure(-text=> $FILTER_IS_ON ? 'turn off' : 'turn on'); $c2->configure(-state=> $FILTER_IS_ON ? 'normal' : 'disabled'); }