my $mw = new MainWindow; $mw->geometry("300x300"); my $num_screen = $mw->Entry(-width => 40, -state => 'disabled', -textvariable => "$ans")->pack(-pady => 30, -anchor => 'ne' -side => 'top'); my @buttons = ( '9','8','7','6','5','4','3','2','1','0'); for (my $i = 9; $i >= 0; $i--) { ###LINE 17 my $button{$i} = $mw->Button(-text => "$buttons[$i]", -width => '3', -height => '3', -command => &numpress($i))->pack(-anchor => 'nw', -side => 'top'); }