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