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 warnings; use strict; my %hds = ('1', '0C8CB35F', '2', '0C9CB37D'); print "rows: " . scalar keys(%hds) . "\n\n"; my $value; my $key; foreach $value (values %hds) { print "key: $hds{$value} \n"; print "value: $value \n"; } print "--------------------------- \n"; my %r_hds = reverse %hds; foreach $value (values %hds) { print "key: $r_hds{$value} \n"; print "value: $value \n"; } print "--------------------------- \n"; foreach $key (keys %hds) { print "key: $key \n"; print "value: $hds{$key} \n"; } Here is the output: Use of uninitialized value in concatenation (.) or string at h line 11. key: value: 0C8CB35F Use of uninitialized value in concatenation (.) or string at h line 11. key: value: 0C9CB37D --------------------------- key: 1 value: 0C8CB35F key: 2 value: 0C9CB37D --------------------------- key: 1 value: 0C8CB35F key: 2 value: 0C9CB37D -- regards, Richard -- tmqrich...@gmail.com