my $bit_10_9; #yes, this is a horrible abuse of globals setbits( 0,0 ); my $bit_10_9_mb = $r2Frame->Menubutton( -textvariable => \$bit_10_9, -menuitems => [['command' => '01', -command => sub{ setbits(0,1); }] .... then sub setbits { $bit[10] = shift || 0; $bit[9] = shift || 0; $bit_10_9 = $bit_10 . $bit_9; }