in reply to hash map to give preference to 1st match
You probably want to use a hash of arrayrefs:
my %results; while(my($score, $url) = getnextpair()) { push @{$results{$score}}, $url; }
Then to get the first URL that had a particular score ...
my $url = $results{$score}->[0]
and to get all the URLs that had a particular score ...
my @urls = @{$results{$score}}
And I'll echo what another monk said - please don't use $value or $val for the key in a hash, it's very confusing.
|
|---|