Whenever you think about "remove duplicates" in Perl, think hashes. In this case, you probably want to have each hash entry be an array containing the numbers:
my %data; while(<>) { chomp; my ($name, $number) = $_ =~ /\A (\D+) (\d+) \z/x; push @{ $data{$name} }, $number if $name && $number; }
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
In reply to Re: Sorting a list and removing duplicate elements
by hardburn
in thread Sorting a list and removing duplicate elements
by texuser74
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |