On Monday, April 22, 2002, at 09:29 , David Gray wrote:

>> Can anyone tell me the best method for removing duplicate
>> array values.
>>
>> eg:
>>
>>  @array = qw( a a a b b b c);
>>
>> becomes after some operation I cant seem to figure:
>>
>> @new_array_or_same = (a b c);
>
> In this situation, I usually use a hash instead of an array so I can
> create highly useful statistics of how often each value occurs.

good reason to not use an autonomous hash.....


what I just learned would solve the problem would be

        my @array = qw( a a a b b b c);
        my @new_array = keys %{{ map { $_ => 1 } @array}};

since the perldoc -q uniq that jeff provided pokes in
that direction - but was 'hash' oriented.....

and, ok, so I am working out the questions:

        So why Exactly do I want to have 'map' to begin with?

given perldoc -f map


ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to