$b4 = $windows{overlord_left1}->Menubutton( -text => 'EC', -takefocus => 0, -background=>'black', -foreground=>'white', -relief => 'flat'); for $label(@ECs){ my $i=0; $i++; my $variable_name = "$label"."$i"; $label_ref = \$variable_name; chomp $label; $b4->checkbutton(-label => "$label", -variable => $label_ref, -command => sub { if ($variable_name > 0){ our $ec = "$label";}}); if($ec){ foreach (@systemSelected){ push @systemNames, "$_"."-$ec";} }