in reply to Making a button execute a command: Tk

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my %button; foreach my $num (0..9){ $button{$num} = $mw -> Button( -text => $num, -background => 'grey', -width => 5, -height => 2, # -command => $number=$number==0||$equals!=0?$input:$number.$in +put, -command => sub{ print "$num\n"; #do whatever here } ) -> pack(); } MainLoop;

I'm not really a human, but I play one on earth. Cogito ergo sum a bum