in reply to Removing Duplicates from an Array

Maybe even -
@arr = map { $_ if !$_{$_}++ } @arr;
Which will get rid of all the duplicate elements in your array. Of course the above is quick, dirty and hackish, but if you're merely munging an array of strings, it should do the job.
HTH

broquaint

Replies are listed 'Best First'.
Re: Re: Removing Duplicates from an Array
by merlyn (Sage) on Sep 18, 2001 at 19:18 UTC
    I'm pretty sure you wanted grep there and not map, and you're altering %_ without warning. As others have said, look at the FAQ entry for proper code.

    -- Randal L. Schwartz, Perl hacker