Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!csus.edu!ucdavis!csusac!utgard!chris From: chris@utgard.uucp (Chris Anderson) Newsgroups: comp.lang.perl Subject: Re: uniq'ing arrays Message-ID: <1990Nov21.073619.23829@utgard.uucp> Date: 21 Nov 90 07:36:19 GMT References: <1990Nov21.021344.16038@fxgrp.fx.com> Followup-To: comp.lang.perl Distribution: na Organization: QMA, Inc., Rancho Cordova, California Lines: 23 In article <1990Nov21.021344.16038@fxgrp.fx.com> grady@postgres.berkeley.edu writes: >grep is a useful unix utility that has a parallel perl operator. >What about uniq? I'd like to see uniq (or something) that strips >out the duplicates in an array. It would be cool if it were >built into perl. I asked this myself several weeks ago ... here's the answer I used from the ones presented by the net. sub uniq { local (@in) = @_; local (%ary, @out); undef %ary; @ary{@in} = (); @out = keys(%ary); @out; } Hope this helps Chris