Re: Sort and remove duplicates
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 28 Sep 2007 15:21:21 GMT
At 2007-09-28 09:10AM, "JimJx" wrote:
Hi everyone,
Got what should be an easy problem.
I have a db (MySQL) that I need to sort on the first field and remove
dups from.
For example, let's say I have Red,1,2,3,4,5 and Blue,1,2,3,4,5 and
Green,1,2,3,4,5 and Green,2,2,2,2,2
How can I come out with Blue,1,2,3,4,5;Green,1,2,3,4,5;Red,1,2,3,4,5??
my %data;
while (<DATA>) {
my $field1 = (split ',')[0];
$data{$field1} = $_ unless exists $data{$field1};
}
my @non_dups = values %data;
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.
- References:
- Sort and remove duplicates
- From: JimJx
- Sort and remove duplicates
- Prev by Date: Re: Small doubt in perl
- Next by Date: Re: string concatentation vs. interpolation: which one is more optimal?
- Previous by thread: Re: Sort and remove duplicates
- Next by thread: Re: Sort and remove duplicates
- Index(es):
Relevant Pages
|