Randy W. Sims wrote:
> How would you implement a version of the function that
> produced an array where the elements are in the same order and only
> the first of any duplicates are kept?

   @uniq = do { my %seen; grep !$seen{$_}++, @arr };

Or, if you want a function:

   sub uniq { my %seen; grep !$seen{$_}++, @_ }

(But Tie::Array is much more flexible in handling the definition of
"duplicate")

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to