#!/usr/bin/perl use warnings; use Tk; my $mw = tkinit; my @buttons; for $i ( 0..5 ) { $buttons[$i] = $mw->Button(-text => "Button $i",)->pack(); $buttons[$i]->configure (-command => [\&printme, $buttons[$i]],); } my $reconbut = $mw->Button(-text => 'Reconfigure', -command => \&recon,)->pack(); MainLoop; sub printme { print $_[0]->cget (-text) . "\n"; } sub recon{ $buttons[$_]->configure(-text => 'Button '. ($_ + 10)) for 0..$#buttons; }