in reply to Hash Question
Consider:
use strict; use warnings; my %hash; while (defined (my $line = <DATA>)) { chomp $line; my ($key, $value) = split '', $line, 2; next if ! defined $value; $hash{$key} = $value if ! exists $hash{$key} || $hash{$key} < $val +ue; } print "$_: $hash{$_}\n" for sort keys %hash; __DATA__ a 1 b 3 a 6 c 4 a 2
Prints:
a: 6 b: 3 c: 4
|
|---|