in reply to finding unique elements in an array
%seen = (); @uniq = (); foreach $item (@list) { unless ($seen{$item}) { # if we get here, we have not seen it before $seen{$item} = 1; push(@uniq, $item); } }
Update: Inserted missed bracket spotted by Martymart
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: finding unique elements in an array
by Anonymous Monk on May 19, 2003 at 09:07 UTC |