I'm creating a list of checkbuttons in perl tk using a loop.
$i=1;
$n=5;
@x=1;
while($i <= $n){
$mw->Checkbutton(->text=>$i,-variable=>\$ckval,->command=>sub{
if($ckval){print $i}
})->pack;
$i=$i+@x;
}
The correct value of i is printed on the screen, but all the checkbuttons seem to be selected. How do I avoid this? Thanks in advance.