use Tk; my $mw = MainWindow->new(); my $var; my @list = qw(jan feb mar apr); my $opt = $mw->Optionmenu( -options => [@list], -command => sub { print "got: ", shift, "\n" }, -variable => \$var, )->pack; $opt->addOptions([may=>5],[jun=>6],[jul=>7],[aug=>8]); $mw->Label(-textvariable=>\$var, -relief=>'groove')->pack; $mw->Button(-text=>'Exit', -command=>sub{$mw->destroy})->pack; $mw->Button( -text => 'Select Random', -command => sub { $opt->setOption( $list[int rand @list] ); } )->pack; MainLoop;