for (0..$numChem) #numChem is the size of the array { my $solvCheck = $frame4->Radiobutton( -variable => \$isSolv, #isSolve is the varible that will hold the index of the solvent -value => "$_" ); $solvCheck ->bind("all","" => \&colorme); #when button-1 is pushed, execute &colorme $solvCheck -> pack(); }