[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Accessing Hash with Value



Hello There MacPerl. This is my first post, though I've been a longtime 
lurker here on the MacPerl mailing list. This is a general perl question 
more than a specific MacPerl question but anyway... what I am trying to 
do is to come up with an easy way to handle poll data. I have set up a 
hash with a key of the question and a value of the number of votes for 
each question. I'm trying to output the results of this poll sorted by 
the number of votes. What I can't seem to grasp is trying to print the 
key when I do a sort based on value. Any help would be appreciated.

Code Snippet:
-------------------------------------
foreach $value (sort values %hash) {
	print "$key has $value votes";
}
--------------------------------------
$key here has no assigned value. How can I get the key to print with it's 
associated value?

-Chris Ouellette

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch