sarvan has asked for the wisdom of the Perl Monks concerning the following question:

hi there,

I have a hash map %result(). which has key,value pair. The key is $val(which has list of floating point values like 0.45458427 and value is $url which has list of urls

I use this hash map to print the url which the highest value in $val(i.e key).

my Question now is, when this $val has two or more values same i.e {value1:0.456234,val2:0.642323,val3:0.456234,val4:0.456234). what happens it prints the val4's url instead of val1's url. since val1,val3,val4 has the same score, I want it to go in order 1,2,3 like that. But it directly prints 4th.

What can be the suggestion..??
my %results = (); foreach my $result (@file_content) { my $tit = $1 if ($result =~ /<title>(.+?)<\/title>/i); next unless $tit; # skip, if tit is not available #print "\n$tit\n"; my $url = $1 if ($result =~ /<url>(.+?)<\/url>/i); my $val = jaccard($tit, $title); #print " $val\n"; $results{$val} = $url; } @results = sort {$b <=> $a} keys %results;#sorts in descending order. my $highest_val = $results[0];#takes the highest value print $highest_val; print "\n\n The Url Ur looking for is: $results{$highest_val}\n#print +s the url of highest values.
My code is this. i cant include the content of @file_content,because it very big. it has title,url,snippet for googles top 10 result. And "jaccard($tit,$title) is a funtion returns floating point value. since its also big i dint include. lets say $val has the following floating point values: 1-> 0.0588235294117647 2-> 0.0555555555555556 3-> 0.0588235294117647 4-> 0.0588235294117647 5-> 0 6-> 0.0555555555555556 7-> 0.0588235294117647 8-> 0.0555555555555556 here i expect the url of 2nd but getting url of 6th..