$menubar = $top->Menu; $file_menu = $menubar->cascade(-label => "~File"); $file_menu->command(-label => "Restart", -command => \&Restart); $file_menu->command(-label => "Exit", -command => \&Exit); $file_menu = $menubar->cascade(-label => "Filter"); $file_menu->command(-label => "All", -command => sub {$fname = "machines"; &Restart}); $file_menu->command(-label => "HP-UX", -command => sub {$fname = "machines.HPUX"; &Restart}); $file_menu->command(-label => "Linux", -command => sub {$fname = "machines.Linux"; &Restart}); #### # Get filter list my @filter = qw(); my $dir = '.'; my $x=0; opendir(DIR, $dir) or die $!; while (my $file = readdir(DIR)) { next unless (-f "$dir/$file"); next unless ($file =~ m/^machines\./); push (@filter, $file); } closedir(DIR); $file_menu = $menubar->cascade(-label => "~File"); $file_menu->command(-label => "Restart", -command => \&Restart); $file_menu->command(-label => "Exit", -command => \&Exit); $file_menu = $menubar->cascade(-label => "Filter"); $file_menu->command(-label => "All", -command => sub {$fname = "machines"; &Restart}); foreach (@filter) { $file_menu->command(-label => "$_", -command => sub {$fname = "$_"; &Restart}); }