Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!morganucodon.cis.ohio-state.edu!jgreely From: jgreely@morganucodon.cis.ohio-state.edu (J Greely) Newsgroups: comp.lang.perl Subject: Re: Uniq, anyone? Message-ID: Date: 12 Oct 90 18:29:16 GMT References: <1990Oct12.075314.15054@utgard.uucp> Sender: news@tut.cis.ohio-state.edu Reply-To: J Greely Distribution: na Organization: Ohio State University Computer and Information Science Lines: 15 In-reply-to: chris@utgard.uucp's message of 12 Oct 90 16:27:44 GMT In article <1990Oct12.075314.15054@utgard.uucp> chris@utgard.uucp (Chris Anderson) writes: >On occasion, I find myself wanting something on the order of: > @foo = (1,1,2,2,3,3); > @bar = &uniq (@foo); This seems to do it, although it strips null fields out entirely (I call that a feature, myself): sub uniq { local($o); grep(($_ ne $o) && defined($o = $_),sort @_); } -- J Greely (jgreely@cis.ohio-state.edu; osu-cis!jgreely)