#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = 'Tk::MainWindow'->new; my $states = [qw[ disabled normal ]]; my @buttons; for my $i (0, 1) { $buttons[$i] = $mw->Button( -text => "Start $states->[$i]", -state => $states->[$i], -command => sub { warn "B$i" }, )->pack; $mw->Entry( -textvariable => \$states->[$i] )->pack; } $mw->Button( -text => 'Apply', -command => sub { blink($_, $states->[$_]) for 0, 1; } )->pack; sub blink { my ($idx, $state) = @_; $buttons[$idx]->configure( -state => $state ); } MainLoop();