Re: deleting duplicates in array using references
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 30 Jul 2007 18:58:50 GMT
At 2007-07-30 02:37PM, "billb" wrote:
i have a multidimensional array, but i want to delete duplicate
entries based on the first element of each 'row'.
my array is:
my @array = ( [UK9004411, A140, B, 0.040] , [UK0030239, H7140, H,
0.030] , [UK0030239, S1393, M1, 0.030] , [UK0012821, H4030, H,
0.010] , [UK0012821, H4060, H, 0.010] );
and I want to end up with
( [UK9004411, A140, B, 0.040] , [UK0030239, H7140, H, 0.030] ,
[UK0012821, H4030, H, 0.010] )
my @array = (
['UK9004411', 'A140', 'B', 0.040],
['UK0030239', 'H7140', 'H', 0.030],
['UK0030239', 'S1393', 'M1', 0.030],
['UK0012821', 'H4030', 'H', 0.010],
['UK0012821', 'H4060', 'H', 0.010]
);
my %hash = map {$_->[0] => $_} @array;
my @uniq = values %hash;
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.
- References:
- deleting duplicates in array using references
- From: billb
- deleting duplicates in array using references
- Prev by Date: Re: deleting duplicates in array using references
- Next by Date: Re: form script question
- Previous by thread: Re: deleting duplicates in array using references
- Next by thread: Using DBI, better option than importing into @array
- Index(es):
Relevant Pages
|
|