Re: How do I find the key of a specific hash element?

[email protected] ((Randal L. Schwartz))
Newsgroups perl.beginners
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "jshock" == jshock  <[email protected]> writes:

jshock> For example:
jshock> my %weekdays = (
jshock> 	0  => "SUN",
jshock> 	1 => "MON",
jshock> 	2 => "TUE",
jshock> 	3 => "WED",
jshock> 	4 => "THU",
jshock> 	5 => "FRI",
jshock> 	6 => "SAT",
jshock> );
jshock> $weekdays{2}; # gives "TUE"

This seems like it should be an array, not a hash.  Just FYI.

Use a hash when the keys aren't consecutive small integers.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.