#!/usr/bin/perl use warnings; use strict; use Tk; my $count = 0; my $mw = tkinit; my $menubar = $mw->Menu(-type => 'menubar'); $mw->configure(-menu => $menubar); my $menu = $menubar->cascade(-label => '~File'); $menu->command(-label => '~New'); $menu->command(-label => '~Open'); my $menu1 = $menubar->cascade(-label => '~Test'); $menu1->command(-label => '~Yee'); $menu1->command(-label => '~Haw'); $mw->Button( -text => 'Push me and look at the menu', -command => sub { my $state = ($count++ & 1) ? 'normal' : 'disabled'; $menu->cget(-menu)->entryconfigure(2, -state => $state); $menu1->cget(-menu)->entryconfigure(2, -state => $state); } )->pack; MainLoop;