Re: perl hash loop: keys() vs values()

2013-06-15 Thread richard
Thanks. I looked at this site while searching for solutions but I probably skipped the section on sorting because I wasn't sorting the hash. regards, Richard -- tmqrich...@gmail.com On Sun, Jun 16, 2013 at 3:17 AM, Peter Gordon wrote: > On Sat, 15 Jun 2013 12:12:56 -0400, richard wrote: > >Hi >

Re: perl hash loop: keys() vs values()

2013-06-15 Thread Peter Gordon
On Sat, 15 Jun 2013 12:12:56 -0400, richard wrote: >Hi > >I'm trying to understand the difference between the keys() and >values () operators. What I'm not getting is why a hash must be >reversed to get the key corresponding to a value? (as stated in >perldoc). Can someone explain this please? > >

Re: perl hash loop: keys() vs values()

2013-06-15 Thread richard
Octavian Thanks for taking the time to write such a thorough reply. My question is completely answered by this section: You can't get the key for a certain value. Say you have the following hash: my %hash = (a => 1, b => 2, c => 3, d => 2, e => 2); What's the key for the value "2"? I was so pr

Re: perl hash loop: keys() vs values()

2013-06-15 Thread Octavian Rasnita
Perl has 2 types of arrays: common arrays and associative arrays which are called hashes. In order to get the value of an item from an ordinary array, you need to specify the index of that array, for example: my @array = (1, 2, 3); print $array[1]; #will print "2" (because the indexes start fr

perl hash loop: keys() vs values()

2013-06-15 Thread richard
Hi I'm trying to understand the difference between the keys() and values () operators. What I'm not getting is why a hash must be reversed to get the key corresponding to a value? (as stated in perldoc). Can someone explain this please? Here is my test script; My perl is freebsd 5.8.9 use warnin