tcf03 has asked for the wisdom of the Perl Monks concerning the following question:
I am able to print the main menu OK, but I am having trouble getting the submenu to print as so:my %menus = ( '1' => { 'ITEM' => 'List and Kill UDT* processes by u +ser', 'ACTION' => $RunCMD->('ListKillProc') }, '2' => { 'ITEM' => 'List and Kill Print Jobs', 'ACTION' => $PrintSubmenu->('2'), 'SUBMENU' => { '1' => ( 'ITEM' => 'Show all P +rinters', 'ACTION' => $RunCMD->(' +showprintersall') ), '2' => ( 'ITEM' => 'Show user +print jobs', 'ACTION' => $RunCMD->(' +showprintersuser') ), '3' => ( 'ITEM' => 'Show singl +e printer', 'ACTION' => $RunCMD->(' +showprinter') ), '4' => ( 'ITEM' => 'Kill a pri +nt job', 'ACTION' => $RunCMD->(' +killprint') ) } }, '3' => { 'ITEM' => 'Manage user accounts', 'ACTION' => $PrintSubmenu->('3'), 'SUBMENU' => { '1' => ( 'ITEM' => 'Unlock us +er account', 'ACTION' => $RunCMD->( +'unlockuser') ), '2' => ( 'ITEM' => 'Change ac +count password', 'ACTION' => $RunCMD->( +'changepass') ) } }, '4' => { 'ITEM' => 'Run App', 'ACTION' => $RunCMD->('APP') }, '5' => { 'ITEM' => 'quit', 'ACTION' => $RunCMD->('quit') } ); .. SNIP .. my $print_menu = \&print_main_menu; my $PrintSubmenu = \&print_sub_menu; #$print_menu->(); $PrintSubmenu->('3'); ################### sub print_main_menu ################### { print "$_\t", $menu->{$_}->{'ITEM'}, "\n" for ( sort keys %menus ); } ################## sub print_sub_menu ################## { my $MenuItem = shift; #print "$_\t", $menu->{$MenuItem}->{'SUBMENU'}->{$_}->{'ITEM'}, "\ +n" # for ( sort keys %{ $menus{$_} } ); for my $Items ( sort keys %{ $menus{$MenuItem}{'SUBMENU'} } ) { print "$menus{$MenuItem}{'SUBMENU'}{$Items}\n"; } #print Dumper %{ $menu->{$MenuItem}->{'SUBMENU'} }; }
Thanks in advance for any suggestions1 ITEM1 2 ITEM2 3 ITEM3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Printing a subset of a data structure
by bobf (Monsignor) on May 01, 2006 at 14:14 UTC | |
by tcf03 (Deacon) on May 01, 2006 at 14:24 UTC | |
|
Re: Printing a subset of a data structure
by jdporter (Paladin) on May 01, 2006 at 16:15 UTC | |
by jdporter (Paladin) on May 01, 2006 at 17:49 UTC | |
|
Re: Printing a subset of a data structure
by Fletch (Bishop) on May 01, 2006 at 15:12 UTC | |
|
Re: Printing a subset of a data structure
by zer (Deacon) on May 01, 2006 at 14:25 UTC |