in reply to Choosing %hash by scalar value
Move "choice" declaration down, and change last few lines to :
Although this does not exactly map to your problem description (since $choice is NOT a string anymore), I suggest that this is a less error-prone approach, and you should structure your code to use this mechanism, if you possibly can. If not, the HOH solution described above is a good choice.my $choice = \%computerAttributes; foreach my $key ( keys %{$choice}) { print "$key\n"; }
"For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Choosing %hash by scalar value
by mellin (Scribe) on Feb 05, 2006 at 23:27 UTC |