Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!apple!agate!usenet From: raymond@math.berkeley.edu (Raymond Chen) Newsgroups: comp.lang.perl Subject: Re: sort -uniq in perl? Message-ID: <1990Sep8.023805.29123@agate.berkeley.edu> Date: 8 Sep 90 02:38:05 GMT References: Sender: usenet@agate.berkeley.edu (USENET Administrator) Reply-To: raymond@math.berkeley.edu (Raymond Chen) Organization: U.C. Berkeley Lines: 12 In-Reply-To: ckd@cs.bu.edu (Christopher Davis) In article , ckd@cs (Christopher Davis) writes: >Well, I went back and hacked this little thing up, but I'm still open to >suggestions for a better way to do it. Howzabout a one-liner? (Though Randal can probably shorten it...) # Teaching Uniquify to handle null strings is no big deal, but # it sort of spoils the cuteness of the line-liner... sub Uniquify{local($prev);grep($_ ne$prev&&($prev = $_),@_);} print &Uniquify(split(//,"JJJJusstt aannothhher ppperlll haaacker,,,"));