in reply to Perl/TK get the Button's text

Or you could use the -command option to pass arguments to a named subroutine. TMTOWTDI. Also note how $i is used as the loop variable.

... my @buttons; for my $i (0..5){ push @buttons, $mw->Button( -text => $row[$i], -command => [ \&buttonpress, $row[$i] ], )->pack; } sub buttonpress{ my $btn = shift; print "button $btn pressed\n"; }