in reply to Choosing %hash by scalar value

Here is another way - Ref to existing hash ..

Move "choice" declaration down, and change last few lines to :

my $choice = \%computerAttributes; foreach my $key ( keys %{$choice}) { print "$key\n"; }
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.

     "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
    Great! Using references is without a doubt the best way to achieve my goal. Thank you.