home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!snorkelwacker.mit.edu!paperboy.osf.org!meissner
- From: meissner@osf.org (Michael Meissner)
- Subject: Re: Removing duplicates from an array
- In-Reply-To: tmhoff@oogoody.Corp.Sun.COM's message of 11 Sep 1992 22:30:25 GMT
- Message-ID: <MEISSNER.92Sep11224350@curley.osf.org>
- Lines: 17
- Sender: news@osf.org (USENET News System)
- Organization: Open Software Foundation
- References: <lb27g1INNaef@jethro.Corp.Sun.COM>
- Date: Sat, 12 Sep 1992 02:43:54 GMT
- Lines: 17
-
- In article <lb27g1INNaef@jethro.Corp.Sun.COM>
- tmhoff@oogoody.Corp.Sun.COM (Todd Hoff) writes:
-
- | Is there a cool way of removing duplicates from an array? I can think
- | of several methods, it could be an option on sort, but what is the
- | perl way?
-
- I would think an associtive array:
-
- %foo = ();
- @array = grep ($foo{$_}++ == 0, @array);
- %foo = ();
- --
- Michael Meissner email: meissner@osf.org phone: 617-621-8861
- Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
-
- You are in a twisty little passage of standards, all conflicting.
-