Kickstart has asked for the wisdom of the Perl Monks concerning the following question:
In this hash I create my list of subroutines I wish to call and a descriptive name for them - they will be elements in a menu in a Perl Tk script:
my %choices = ( 'fs_sub' => 'File Systems', 'mem_sub' => 'Memory' );
Further in the script I attempt to call the list in a foreach loop:
foreach (keys(%choices)) { $choice_menu->command(-label => $choices{$_}, -activebackground => '#CCCCCC', -command => \&$_); }
All seems to work, except that the second (last) set of keys/values in the hash is repeated. Or more appropriately, the foreach loops twice on the last set, giving me:
...in my menu.File Systems Memory Memory
Any ideas why it is doing this?
Kickstart
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perlref repeats last of array
by Zaxo (Archbishop) on Nov 26, 2001 at 12:16 UTC | |
by Kickstart (Pilgrim) on Nov 26, 2001 at 12:21 UTC | |
by demerphq (Chancellor) on Nov 26, 2001 at 12:47 UTC | |
|
Re: perlref repeats last of array
by jlongino (Parson) on Nov 26, 2001 at 11:56 UTC | |
by Kickstart (Pilgrim) on Nov 26, 2001 at 12:02 UTC |