... for my $i (0...$#a) { $f->Checkbutton(-text => $a[$i], -command => [ \&fun, $i ] )->pack(); } MainLoop; sub fun { my $j = shift; print $a[$j]; }