my %seen; my @data = grep { chomp; not $seen{(split /\|/)[0]}++ } <DATA>;
This solution will load the entire file in at once, so if you are using large files this would not be the most memory efficient solution.
Whenever you need to remove elements from a list of items think grep.
In reply to Re: how to remove duplicate based on the first column value
by cees
in thread how to remove duplicate based on the first column value
by tariqahsan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |