my %results = (); foreach my $result (@file_content) { my $tit = $1 if ($result =~ /(.+?)<\/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#prints the url of highest values.